Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp23054lqz; Fri, 29 Mar 2024 07:27:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVWXF7LIBa6dkAv9qEdTiQsnibNFxtXQl3bbqrO4dXFXW9q6Z11dJz5U5KpGKq4+LDP6C+O8jWpS/Uzql1VvA2M7uZxEaktmaFivSiJOw== X-Google-Smtp-Source: AGHT+IF0U01isz6hVBesnRg+GmWFE7MQveo5LMAOIAqgEsIWurefkhoRdWvgd3zPbhqieaWJnNil X-Received: by 2002:a17:906:b241:b0:a47:5231:754f with SMTP id ce1-20020a170906b24100b00a475231754fmr1685122ejb.7.1711722431242; Fri, 29 Mar 2024 07:27:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711722431; cv=pass; d=google.com; s=arc-20160816; b=X8Rou20c6AdxiBaoIpbGA7JA7cyJs9Z6prspMoWTgThPKyEc52j3FVYX5v7zQF4Eui ycv9jaGC/3m6SG54Yz9kkmwtJMTPLp+Tye5ykCmQWYxtyvRnjdYvAPu9o5Fgek0Sz14h R5y19DH123ZFCbmAmWTPX3ZlFF6SGti7YQdHbV1Bn35GFWQ/qBjxNBYG54A/3kvKHKj/ TbunlXOhOVeMOUEJcuqu8RX9v8INsK1+M0pMntsbVspWO8OTouFdgVoGXxW6VvCHmNIE 0lJ5W/YklnXOS9i3fg6uxNqVMpKm2rCNqLBq5UwJ4slyR+qtCld5s+okx/E9tHU4f4HQ UVAg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=C5cysrmguRPwUuWlQIgUj8M1el7BH4hynGtuk4clipY=; fh=vyddssDnPLe3KHkBCjiTD3gytU8hNI8Z+OhZjKJYA50=; b=Vgu/XkTN/Vbmb3hOo2P3wCbV65t7au+xtx2sESvSMqfiU2RrkQKu+ctV/EeYSbqa3N vKo3Mhf+3bsV7KBJW3WZSnJ2zBwA/kIB0j6EhH7fkJ4iIwADYdIb5hN09ZOT/XnoTwta G2eZExQYyn7EENiGa0k9+YL61fo/1dpSvKc55xW15JHdpWJgmG8SjEs6OEI5fV54Mhn0 Ne6siYCCTJLlQ8H2M1AbZG5pkLn30Jpx5RVH5ESqu4FCLE/Ric5xINdTf5voGB/oDUxo 0DpU+3Zsq4wB/JBFwGO46t19CuU+KIrVa78QksfYEkPguSaK+8YUSvQwQPr8u1WOe+Sb aeJw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M4sI7Sfg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124894-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124894-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gb35-20020a170907962300b00a4e2653f545si1572857ejc.181.2024.03.29.07.27.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 07:27:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124894-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=M4sI7Sfg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124894-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124894-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id B01C81F26FC3 for ; Fri, 29 Mar 2024 14:20:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDBF5233AA8; Fri, 29 Mar 2024 12:46:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="M4sI7Sfg" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E5F9B233A91; Fri, 29 Mar 2024 12:46:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716382; cv=none; b=ahk8LK/iPpYQmfzVCq6/6YnyO6QdkXJrWtTWHGe8B2GM9Wkwm93i6vV89NYkCeLuq492y8OjPUc3FnwTAw4hVgZBrq8xSZGAtgTYAxoFPkU2vID6HAi58eb7xOBtVh0ya4q6DFCAURuw6HLICANgGKmuMt/KRJKkVVe5EOGrPJQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716382; c=relaxed/simple; bh=kaa8ifzx6hH+2K+Lax/DSzP0zj6PNJSy9o/mAG2JK5Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NyOAxSDdeICXUCLHjB9gAsxHFNaeNs2ET8802/wbKMX3uTqclfto3nvwYSL7ZEGV1jarl9u4ZTGlVByrml1PTOn2SrObnVAP18zA+flGgDN+5yzXB6faLbnFRFdVZLztgZEbCtgCDVI9pDZgABfFy9SnmdCtNiacyRCmfu37Vt0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=M4sI7Sfg; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB326C433C7; Fri, 29 Mar 2024 12:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716381; bh=kaa8ifzx6hH+2K+Lax/DSzP0zj6PNJSy9o/mAG2JK5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M4sI7Sfgm0sjA1UnKobFnPFXcBGsIQMdE9oLM2XoKZiCqM7P+KnzPitbGxLkmlFJP ScypDL5/ji23i19mlGLThX5Op43vPduFPKr1eNEgcnAxdckGxvBcQGJk4kUgo1bx0d ol1eTfuEPt+yo5eILe0Jb7DlOMtveQED50GMhZ0iIPPwaxDTcQXQUdvMZPNHG76HFL hMcq5Qowyd+DdaDgV70hz+KuZCskJ4lyyKvh3h/fFzIidt0qqwM4784MdcXqWB5kmS LjWgPwa/ewudz/gdPJFUFNttjCXhcVXpFUivbZ6rHyafRPHyH3DW+ozOMlijLALnY4 xmPmmvna7hYAg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Justin Tee , Himanshu Madhani , "Martin K . Petersen" , Sasha Levin , james.smart@broadcom.com, dick.kennedy@broadcom.com, jejb@linux.ibm.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 10/52] scsi: lpfc: Fix possible memory leak in lpfc_rcv_padisc() Date: Fri, 29 Mar 2024 08:45:04 -0400 Message-ID: <20240329124605.3091273-10-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329124605.3091273-1-sashal@kernel.org> References: <20240329124605.3091273-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.83 Content-Transfer-Encoding: 8bit From: Justin Tee [ Upstream commit 2ae917d4bcab80ab304b774d492e2fcd6c52c06b ] The call to lpfc_sli4_resume_rpi() in lpfc_rcv_padisc() may return an unsuccessful status. In such cases, the elsiocb is not issued, the completion is not called, and thus the elsiocb resource is leaked. Check return value after calling lpfc_sli4_resume_rpi() and conditionally release the elsiocb resource. Signed-off-by: Justin Tee Link: https://lore.kernel.org/r/20240131185112.149731-3-justintee8345@gmail.com Reviewed-by: Himanshu Madhani Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/lpfc/lpfc_nportdisc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_nportdisc.c b/drivers/scsi/lpfc/lpfc_nportdisc.c index b86ff9fcdf0c6..f21396a0ba9d0 100644 --- a/drivers/scsi/lpfc/lpfc_nportdisc.c +++ b/drivers/scsi/lpfc/lpfc_nportdisc.c @@ -748,8 +748,10 @@ lpfc_rcv_padisc(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp, /* Save the ELS cmd */ elsiocb->drvrTimeout = cmd; - lpfc_sli4_resume_rpi(ndlp, - lpfc_mbx_cmpl_resume_rpi, elsiocb); + if (lpfc_sli4_resume_rpi(ndlp, + lpfc_mbx_cmpl_resume_rpi, + elsiocb)) + kfree(elsiocb); goto out; } } -- 2.43.0