Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp1076962lqh; Fri, 29 Mar 2024 06:41:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWKUmRixOYh3wZ+Y6Am/kL454r4ftLS5Vd/k2ym3nmXANlKmYdhYO4+VBqvFFpSP3jc4PFTepgk3NzfqgI8Brc+6iP+6mXvLKnf9fimag== X-Google-Smtp-Source: AGHT+IFDl3oY0nRgdc9Nba4r5VGICkKsRLOrdHBorDQOFjMX5wIV54ReNpeRQng4a8KHw2zDhZp0 X-Received: by 2002:a17:906:6052:b0:a4e:2777:37c7 with SMTP id p18-20020a170906605200b00a4e277737c7mr1455764ejj.49.1711719716401; Fri, 29 Mar 2024 06:41:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711719716; cv=pass; d=google.com; s=arc-20160816; b=sUBvrwnEy1ivIMD8KAFil714RLsmVwLAg3Lz9IlTzyByVdioqMzU4bZFTNsORUhShx TmJD8i/ciAD/NtwJsLIntFv4mdjaYJTmsA+VlajZe+mzTyNqqAmRr8K6nvr7kpwRP5pF isRPVULE0oO+g5onoIIp6VfcVnZ1IMcUpvupnJFTOUl+WcwaG7/9BfTS55UxPKCVfW+f YfYlui/3v0ZG/D4Mbh1Ay6bj1FjrbQr1WTD6Q1KuRx2laj1Xq9DgDizkoJghkWG1jJfH NxE7vsnKlxZCU+ZEFuCjfIVxzvSKbKZESlErE1vtrWgbAxbGkk7RPbkn/hQeo3am73gA loNA== 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=BpQ3lYFLYyE0cldicujdZfp+5urccbQ7Ep/gnbPD90E=; fh=vyddssDnPLe3KHkBCjiTD3gytU8hNI8Z+OhZjKJYA50=; b=BNGsoNEIOmnjWHvJactv6o9eX2jfIyqJLQyL00GJoph6cju/RiNd5K06y1cUsTTlCh O6HHNZ/7xwy81a9nJgy/wmWO5UomqOm5Xuud33yuu7Dq0tUglJ40MxFNVDc9Se9+wSL/ NuA8zVS+Llsp129iVTECZBpRmBqyeQZWvgbIo24TVzK/i1IilkWeDs25vwVSXDdKvytg oD/h7kJ3q6aDODTIvINDDKfUjlToq+lFDr1W+NWJBkzwAS3dr/Dgcep8mZY/jlExx6lo Auj3Ty6JiaxBHMNIBLbDARCWwirjMnyIDC6Hdv7eEfd3MbjGMc7xtGB7AymfFOaKiFNt KC7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RC1guOuC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124727-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124727-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 sd6-20020a170906ce2600b00a46da73535esi1744434ejb.961.2024.03.29.06.41.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 06:41:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-124727-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=RC1guOuC; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-124727-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-124727-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 A6DE11F25C5F for ; Fri, 29 Mar 2024 13:35:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9D495178210; Fri, 29 Mar 2024 12:40:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="RC1guOuC" 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 AF43E178205; Fri, 29 Mar 2024 12:40:20 +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=1711716020; cv=none; b=KBwc+CI3uQ/jx6L4cCsgFU4JMUTQzRiexAUq9n33h/ET6xOl3ZkH1uMuFbEEW0Y1h9S7yFl6JFg7KMvuhWGGEOBjZcKwQ5tJxZw0RWsGFJbXf1seUapMyCBkyjbopqcz5Vi6iwq5A45fbMtVFyhbvJtAgvjt3G69bxebntQ12Uw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711716020; c=relaxed/simple; bh=24mpTUxu3EPleptzaMEqL9rwWlByY7e/6uMWdLp/ep4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rF4RJpfSnkz9HxrPlli+utfG5VQ9gOCOpnYvMNNj2xImzUbgxLN1KoCAwIEMUe1oEYhvRCrY7SsRXE1wl9KlbEjrQi57TP53b3zsdZ5sqsETKK8qYq8u//02hl0CR8zET8gksCvB++xM2SpvWh/PM8o8oTghpRHJaVRY6jsPgvA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=RC1guOuC; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 48036C43390; Fri, 29 Mar 2024 12:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711716020; bh=24mpTUxu3EPleptzaMEqL9rwWlByY7e/6uMWdLp/ep4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RC1guOuCeO2FNHVMCIXPErpU2xuxwrpIm2xBaaPmdsNUczjYQvRY4tL7Nz7P5I0ls EsWG9JljX5O7Wo/l0ob7HzsfSteHUzbMsZNzqMWuKO3K1oX2YuyM8gLosB/UhyM4ds 1/qYoogQuzCAQCtQI+/jsgOg61aTS6b96fvj0UP+Up1jAbTOHqfeV7IM8Nxs4gMNkt 1AeBKDWK5KGqcX2yD5msnJnaS6hrfzeb5w9DYHdvmK0ZnqMqkDmX+buqj/9FhRGZlS 1lgI3vAPy4XQaHXjFOWQ3I4AmheUyv3bNK1kP9/97ob8Y3/CESCkm2YZRG8MKL0bRq gD16fKOgK5vRg== 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.8 18/98] scsi: lpfc: Fix possible memory leak in lpfc_rcv_padisc() Date: Fri, 29 Mar 2024 08:36:49 -0400 Message-ID: <20240329123919.3087149-18-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240329123919.3087149-1-sashal@kernel.org> References: <20240329123919.3087149-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.8.2 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 d9074929fbab8..b147304b01fa1 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