Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1738501ybb; Thu, 26 Mar 2020 06:29:58 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuGPxGk798Dn74TsTOTOBM6aaULgbA6B2jvXCU6ktfsL1I8e+f6sk1WTeiGh1OSs+npDz/P X-Received: by 2002:aca:55ce:: with SMTP id j197mr21612oib.84.1585229398146; Thu, 26 Mar 2020 06:29:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585229398; cv=none; d=google.com; s=arc-20160816; b=PjKsakb3wu4TMZIHg6VEnbjeYiOWfi1nsscrc8z38m0iFtUlO4sv7lMqvB+jqwtpMx nLeUBSIKlQ/2C+z8NIs/dfuuaAlYHq4IbRE4fcFJHdms8P8L+aJSJJ0Wwx1TXkDZsyt6 kEHSXqf99kcs8b+kXIuOgOuD5jJjCoOOwSPYFSpMj+LPrlRnBg3fYuhKQUteau7SfuOK Gmmo7aB/Q/NFCuNu+wEuEhULIeGktmu3bpWg0nHIB0ANAuvIJgFJFRVZGmbKbWgzT+Ro 4mTXdnhpv6vCRouCG4qtwxoxtw1FCNS5+gIp9jUuE22QZENyQRwrB4GNsEgaERMJySPn ytrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:to:from:date:dkim-signature; bh=9VMBXAMCwL7qm/FeM98BMJBlfVZIr+3WQNOcgxok4qo=; b=AupB7lriLz+GTO99wWM2wyzFTEmuS4cBBkucFpVrkNWGcuvIpMWY0x7ujiaNZX2SV4 bQnHItyVSWMCPPaU3SnQDPA+yJfOl8za93XemApgIslOUm/0bzod3+6B4kyYEYiR3WKw xUxSupv+LQXj1jDhD7C2q+tr6BGCiXXc4yiqKTAWSej526urK59a+FDuVuHpt0wxptQT KvlTCpIUuaMJvYB/sriafpa5PKhsmtDQuqXwFWwRrHiDkxkAdrV0hcWArk6pyPBMHUky 0Cb2OC6RZITEEqVD4WgALXOJ0y0AG7ldBPpAEyJFep6rUuRUiEgjOsYVyvYfskakGzVV 4IFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OmakIFQf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t132si986080oih.173.2020.03.26.06.29.43; Thu, 26 Mar 2020 06:29:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OmakIFQf; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727695AbgCZN2a (ORCPT + 99 others); Thu, 26 Mar 2020 09:28:30 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:36567 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727547AbgCZN2a (ORCPT ); Thu, 26 Mar 2020 09:28:30 -0400 Received: by mail-pl1-f194.google.com with SMTP id g2so2129819plo.3 for ; Thu, 26 Mar 2020 06:28:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :user-agent; bh=9VMBXAMCwL7qm/FeM98BMJBlfVZIr+3WQNOcgxok4qo=; b=OmakIFQfxCrQNfd8PVzCQSci2n6MNA7igCtPFOFRNTpd5G1xLmXqSri+roMLEcbbpm wcGG2/KlQKEL4Y4uNNLJ9eWMmVGrt2TL7ymP7PvOnI60QX9GEFMRaPOVOFWhQDi13/Ek fdk9qkgfiZMG5u8RdMKGWbP0emmHEwEWFlZbIVOFdt1Cmc8jQGZXdzgaC03xkNRcDRcU JzKun+rZD4iThoE1OhE406GpUQbLhZopSRbtmeZyZoXXT8YVa9207fBrayLquQHQ8KnD 9X6na/wlphZyexHgf4kx9Lebgy9a6Z7jhWhXcbF6zFFh6y71Wllrq1tJcNbwSrYrFWSs l54g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:user-agent; bh=9VMBXAMCwL7qm/FeM98BMJBlfVZIr+3WQNOcgxok4qo=; b=jIr+Tb1yNsdyyHHMvRmWsqL9AVWlEgCq+E3BQoiwejJlSjalil+unebhZYXALoyVR0 DtCfno2o0lZY5S/ieawoiUDw1dEnoeKDFcQStjrdGeoa97Hj/20Wu0XDC3MWemm/eXXp HmRNMz09Z0xdM0PuPsiZZyilO8MKdriEIQKZExEPkocfq5mXJnxmXycriLT61GcgLVuT cHBMmZ29r8ocY19TiPSIHyQcHmjPgavF4x/17f9L724zZO+zFh5nKKhSLMgpjC3wO05T KBvcqOLZIWiYlTUvFEGouYO9cB3AdkolvEvSKb3zRxwnU1pNfZCQCnOAIc/Y0fHSV5lW Y6tw== X-Gm-Message-State: ANhLgQ3R178wzfdI+n0Ek25+QDfimZFzEhQeGrgqcSBFPHQ0LuQw1zo4 7Lvnyh/pBOU3FiUShEPNf3Q= X-Received: by 2002:a17:902:aa4c:: with SMTP id c12mr8508293plr.168.1585229309170; Thu, 26 Mar 2020 06:28:29 -0700 (PDT) Received: from simran-Inspiron-5558 ([2405:205:1208:56c8:8124:5e4b:ea06:7595]) by smtp.gmail.com with ESMTPSA id q19sm1672840pgn.93.2020.03.26.06.28.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Mar 2020 06:28:28 -0700 (PDT) Date: Thu, 26 Mar 2020 18:58:23 +0530 From: Simran Singhal To: Greg Kroah-Hartman , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, outreachy-kernel Subject: [PATCH] staging: rtl8723bs: hal: Remove NULL check before kfree Message-ID: <20200326132823.GA18625@simran-Inspiron-5558> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org NULL check before kfree is unnecessary so remove it. The following Coccinelle script was used to detect this: @@ expression E; @@ - if (E != NULL) { kfree(E); } + kfree(E); @@ expression E; @@ - if (E != NULL) { kfree(E); E = NULL; } + kfree(E); + E = NULL; Signed-off-by: Simran Singhal --- drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c index 1e8b61443408..cf68193a167f 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c @@ -480,10 +480,8 @@ s32 rtl8723bs_init_recv_priv(struct adapter *padapter) precvpriv->precv_buf = NULL; } - if (precvpriv->pallocated_recv_buf) { - kfree(precvpriv->pallocated_recv_buf); - precvpriv->pallocated_recv_buf = NULL; - } + kfree(precvpriv->pallocated_recv_buf); + precvpriv->pallocated_recv_buf = NULL; exit: return res; @@ -518,8 +516,6 @@ void rtl8723bs_free_recv_priv(struct adapter *padapter) precvpriv->precv_buf = NULL; } - if (precvpriv->pallocated_recv_buf) { - kfree(precvpriv->pallocated_recv_buf); - precvpriv->pallocated_recv_buf = NULL; - } + kfree(precvpriv->pallocated_recv_buf); + precvpriv->pallocated_recv_buf = NULL; } -- 2.17.1