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 38966BA32 for ; Tue, 7 Mar 2023 17:14:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B4D4C433EF; Tue, 7 Mar 2023 17:14:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678209254; bh=T2dWdKsmhepJqZkxnM7zgUU0ETz4tZnan51isedxU3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=C+NsCWIC/Fq8rWIrJ1KbgOHgU8rV3ayvdkEaUU6AfTufIa/SniAo+QgLYvLz6rPcE dICOaDHwd2Bm/f+CK28Ro3lLzcNP3lK4Km48obZQzWEPMGahNWwHPSW01h1xyRlEu6 25i7MEKWCFuXDSIAKnECZiC019EAXuM7auvwDvlg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Qiheng Lin , Stefan Haberland , Jens Axboe , Sasha Levin Subject: [PATCH 6.2 0119/1001] s390/dasd: Fix potential memleak in dasd_eckd_init() Date: Tue, 7 Mar 2023 17:48:11 +0100 Message-Id: <20230307170027.269349620@linuxfoundation.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230307170022.094103862@linuxfoundation.org> References: <20230307170022.094103862@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: Qiheng Lin [ Upstream commit 460e9bed82e49db1b823dcb4e421783854d86c40 ] `dasd_reserve_req` is allocated before `dasd_vol_info_req`, and it also needs to be freed before the error returns, just like the other cases in this function. Fixes: 9e12e54c7a8f ("s390/dasd: Handle out-of-space constraint") Signed-off-by: Qiheng Lin Link: https://lore.kernel.org/r/20221208133809.16796-1-linqiheng@huawei.com Signed-off-by: Stefan Haberland Link: https://lore.kernel.org/r/20230210000253.1644903-3-sth@linux.ibm.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/s390/block/dasd_eckd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c index 5d0b9991e91a4..b20ce86b97b29 100644 --- a/drivers/s390/block/dasd_eckd.c +++ b/drivers/s390/block/dasd_eckd.c @@ -6956,8 +6956,10 @@ dasd_eckd_init(void) return -ENOMEM; dasd_vol_info_req = kmalloc(sizeof(*dasd_vol_info_req), GFP_KERNEL | GFP_DMA); - if (!dasd_vol_info_req) + if (!dasd_vol_info_req) { + kfree(dasd_reserve_req); return -ENOMEM; + } pe_handler_worker = kmalloc(sizeof(*pe_handler_worker), GFP_KERNEL | GFP_DMA); if (!pe_handler_worker) { -- 2.39.2