Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp755077pxb; Thu, 19 Nov 2020 13:01:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxlCRPQHK3uKUjcuzPSFUUAjYcI9r54cSvAeUzX+ZpC3eXdoquP8ErppMVz7uF58DPR0P5i X-Received: by 2002:a50:9fc1:: with SMTP id c59mr30796153edf.59.1605819698293; Thu, 19 Nov 2020 13:01:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605819698; cv=none; d=google.com; s=arc-20160816; b=e5i6fJwT0AQ8P5D9uZfddhZecxV97yjcJsBOUSgTNmNQ5eZJN3/jVyS/r9DQeTucIe pQ3n0+taLZvFAYedcddRZ+vBOB42IdaFoIe5A/EptY2b7KqZWAj4bb1n3TsC/fzCuDfs J5yXoybC+4RJbJTQmPtUlkQl4M4PX+s9ev/9dzoE1mJQ7HgxcpXzzl9pOgzGvdICKqBs as8qNMRCxW5nd+U1nDK4OGi7Jw+Gfk4FlG5hJ61ZFKAMGrKJOH3DdNvBLK9+xHXbmsrw xFikCPXO6rOCHJu9Agrb6sAfgUWmumvRgKny1VgLUrVG8K6XbE/M4sRol81vdHMYdCLj ydVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=mTDmLT3ef+Ux2dZs2Csuaw9w1XAco/LHGRs5BszPztM=; b=dHLrFoSxssAGVhXvAe8ticehOb4Np7oo5CNlFnd8jhJUfRCF4TQ1lyguTjlKpjVCuB LMRUMSz/m94OFz2QDcp+TO+Ttv4hF6z5FsTbyU6PT6x9DDlTQfhVDgT+ZAtCb7g0KxeM ndDIhi+Ju94hflngZhERgs5b8a7icaoNmENtizDegCQq27Eh5no+tyODkouOsjhLtZ2a vYF+XYj4eHMgnlf4AwX7vGIQ7qM1t1pMrUSNxAIHCcoglc+C+7kVZkz4Y/9Io4e7NpcD JiI4RQXgzMaNhY254qFSf7NJsd+0drZQNJxqrAaXyAXtZHA9FKWlRgvIVFyCe/CeiZ+W nGHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=OOvd+wAK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i59si526246edd.308.2020.11.19.13.01.14; Thu, 19 Nov 2020 13:01:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=OOvd+wAK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726475AbgKSU7D (ORCPT + 99 others); Thu, 19 Nov 2020 15:59:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726199AbgKSU7C (ORCPT ); Thu, 19 Nov 2020 15:59:02 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB7A0C0613CF for ; Thu, 19 Nov 2020 12:59:02 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id bj5so2819023plb.4 for ; Thu, 19 Nov 2020 12:59:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to; bh=mTDmLT3ef+Ux2dZs2Csuaw9w1XAco/LHGRs5BszPztM=; b=OOvd+wAKtilxrn5VJHRi9GHx+K+4tEuCayZRiXJdoCB4a8aUpvLCwC0a2MxXIiNyVH 1BewdeGe1tHx9gwe666rbEFbjtE14o32tbQXvZ/NxtTlmivNKFh2OEuxB6f9eSSUNd9q h6hkzbNJ55v5ylg4nyK7M7KVgf9kahOy0bDyA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to; bh=mTDmLT3ef+Ux2dZs2Csuaw9w1XAco/LHGRs5BszPztM=; b=a30w9/mHPh1QHo7cYyZDu3xgUCwAMPr/B+264DeGuN/rQGDLYnpGV6tqRGw9aK63Mc E+oxWXwdQzKzfzxtjY+qS9J8KRZS93V5B8eqhUwpgwbKGXE0mRT8Fv+VpLu5ZB9L20nZ erGWT+SXxKj4D1vv2Otuv8SrM7gvCifSAdHoSitiO1PCKWfvWg4+49cPw8hBawW/kr9h p2Jlk/DnR/r5fpl1c2C5j+aMDH6fPaxDYng6/bNrqpaUbmPLODbxjMeSt9B1pfm865ZM ySYpT5b0gvXR8/ABD08OuSh5U3hxllsFicolV13afeyzBv2nvfYEp6Ak6AjRJh65YmYL yh1w== X-Gm-Message-State: AOAM530agVyLBkQYPQKQG6IMm8cbRRO309PIwcBcQftWF1VTIL9a8pTQ oRpQkBMSzX2iDMd/M+GsPc/96NS7MKkfvibAlcDBMrk0tHDO1DKAO7wNWlFDLTbLGpFHs4jvbXF pB5Z2WQxDynEgjKwSXlMo3TzUz/Vhow5Ho6aIO04obdKcFA8uM/k90j2j/qWHV/5Q825cPAUQ41 dXCJRQDQ== X-Received: by 2002:a17:902:b58a:b029:d7:d45c:481c with SMTP id a10-20020a170902b58ab02900d7d45c481cmr10988315pls.55.1605819541664; Thu, 19 Nov 2020 12:59:01 -0800 (PST) Received: from [10.69.69.102] ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id g15sm745974pfk.184.2020.11.19.12.59.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 19 Nov 2020 12:59:00 -0800 (PST) Subject: Re: [PATCH][next] scsi: lpfc: Fix memory leak on lcb_context To: Colin King , Dick Kennedy , "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org References: <20201118141314.462471-1-colin.king@canonical.com> From: James Smart Message-ID: Date: Thu, 19 Nov 2020 12:58:59 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.3 MIME-Version: 1.0 In-Reply-To: <20201118141314.462471-1-colin.king@canonical.com> Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="0000000000006415b905b47bff9e" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0000000000006415b905b47bff9e Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US On 11/18/2020 6:13 AM, Colin King wrote: > From: Colin Ian King > > Currently there is an error return path that neglects to free the > allocation for lcb_context. Fix this by adding a new error free > exit path that kfree's lcb_context before returning. Use this new > kfree exit path in another exit error path that also kfree's the same > object, allowing a line of code to be removed. > > Addresses-Coverity: ("Resource leak") > Fixes: 4430f7fd09ec ("scsi: lpfc: Rework locations of ndlp reference taking") > Signed-off-by: Colin Ian King > --- > drivers/scsi/lpfc/lpfc_els.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/drivers/scsi/lpfc/lpfc_els.c b/drivers/scsi/lpfc/lpfc_els.c > index 03f47d1b21fe..0d3271b4c130 100644 > --- a/drivers/scsi/lpfc/lpfc_els.c > +++ b/drivers/scsi/lpfc/lpfc_els.c > @@ -6515,18 +6515,20 @@ lpfc_els_rcv_lcb(struct lpfc_vport *vport, struct lpfc_iocbq *cmdiocb, > lcb_context->ndlp = lpfc_nlp_get(ndlp); > if (!lcb_context->ndlp) { > rjt_err = LSRJT_UNABLE_TPC; > - goto rjt; > + goto rjt_free; > } > > if (lpfc_sli4_set_beacon(vport, lcb_context, state)) { > lpfc_printf_vlog(ndlp->vport, KERN_ERR, LOG_TRACE_EVENT, > "0193 failed to send mail box"); > - kfree(lcb_context); > lpfc_nlp_put(ndlp); > rjt_err = LSRJT_UNABLE_TPC; > - goto rjt; > + goto rjt_free; > } > return 0; > + > +rjt_free: > + kfree(lcb_context); > rjt: > memset(&stat, 0, sizeof(stat)); > stat.un.b.lsRjtRsnCode = rjt_err; Looks good. Reviewed-by: James Smart -- james --0000000000006415b905b47bff9e Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIQPwYJKoZIhvcNAQcCoIIQMDCCECwCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg gg2UMIIE6DCCA9CgAwIBAgIOSBtqCRO9gCTKXSLwFPMwDQYJKoZIhvcNAQELBQAwTDEgMB4GA1UE CxMXR2xvYmFsU2lnbiBSb290IENBIC0gUjMxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMT Ckdsb2JhbFNpZ24wHhcNMTYwNjE1MDAwMDAwWhcNMjQwNjE1MDAwMDAwWjBdMQswCQYDVQQGEwJC RTEZMBcGA1UEChMQR2xvYmFsU2lnbiBudi1zYTEzMDEGA1UEAxMqR2xvYmFsU2lnbiBQZXJzb25h bFNpZ24gMiBDQSAtIFNIQTI1NiAtIEczMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA tpZok2X9LAHsYqMNVL+Ly6RDkaKar7GD8rVtb9nw6tzPFnvXGeOEA4X5xh9wjx9sScV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