From mboxrd@z Thu Jan 1 00:00:00 1970 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 25EAE6FA0 for ; Mon, 16 Jan 2023 16:45:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EC81C433D2; Mon, 16 Jan 2023 16:45:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673887550; bh=avuwxkWSqhhsYkBc59kbGHSBMHLm336qKI64I/3tvJM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q5DCIwoK7WjHxuoNzqr7Glf4QHPAC7gPWB+1Wi0rAJNovcP89ZJWKpJ1z8Q8RI7cA dU0CFKPc37FLBYESnu0vvPaTrvLWxM/HbCjt7ECUWctZnClzdlrzKXVMmLxYHlDCgh sY5ZBupJuwvTnJUcutI/T+zHXbIBLmMYjeQgaoJs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuan Can , Ming Lei , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 191/521] scsi: hpsa: Fix possible memory leak in hpsa_init_one() Date: Mon, 16 Jan 2023 16:47:33 +0100 Message-Id: <20230116154855.605916596@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154847.246743274@linuxfoundation.org> References: <20230116154847.246743274@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Yuan Can [ Upstream commit 9c9ff300e0de07475796495d86f449340d454a0c ] The hpda_alloc_ctlr_info() allocates h and its field reply_map. However, in hpsa_init_one(), if alloc_percpu() failed, the hpsa_init_one() jumps to clean1 directly, which frees h and leaks the h->reply_map. Fix by calling hpda_free_ctlr_info() to release h->replay_map and h instead free h directly. Fixes: 8b834bff1b73 ("scsi: hpsa: fix selection of reply queue") Signed-off-by: Yuan Can Link: https://lore.kernel.org/r/20221122015751.87284-1-yuancan@huawei.com Reviewed-by: Ming Lei Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/hpsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 19d9c30be09d..1a4fc8b8a9cd 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -8841,7 +8841,7 @@ static int hpsa_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) destroy_workqueue(h->monitor_ctlr_wq); h->monitor_ctlr_wq = NULL; } - kfree(h); + hpda_free_ctlr_info(h); return rc; } -- 2.35.1