Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1023801rwb; Thu, 8 Dec 2022 06:01:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf5mw1PLLi2vcWt930/XkzYPLw16JC3NDbHUNYq+iEJP+op1XlcMs/YJsaULjVD+S5KUI4/9 X-Received: by 2002:a17:902:c184:b0:189:680e:c2e4 with SMTP id d4-20020a170902c18400b00189680ec2e4mr62283953pld.84.1670508091755; Thu, 08 Dec 2022 06:01:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670508091; cv=none; d=google.com; s=arc-20160816; b=Qx4pehm7Tz4qdG8LFdY1OryuF9xpszreJVyz8xNphFSThyLpDYjAWg+oLgYSc9Hcib Hkj/JJrkLNW/MPr/0wVvDP4LHLJIZ3Sng1H7ZB5Y7S6BIJDanYI/IIVqZ1uSoSg3D4ig +Nk4d1/Cupd6xp7M3fxAj3p/98x5bSeeOSL8pnEcVQWNynngKrfhcj/OYq51DN208EmP z8eqxLzy1529oFTCITm9Si/7Gai2ECnmeHRY8iTtCaroTIJe4re+iqBraDnxOaHJQh11 P7DSDSphVS7Wk7aWJITgSFL9YXf5CZfmCngJBJbu/P66XjmQKM5i8XhHg9HANPohaa7C Fztw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=OsltF7iXQVBg2kVpzIG7yUhHF9ykC0BTUvfnPiRSh+o=; b=OITfi6rm3kxKfs/fZKVGkioa7IrCfE/wmufJz9YgJfaME/OXjynBWvtULimaio9/ca J/UQGvTNROkjvUK4jGo9lwRFMd6WaBFwd2u0vaoo/24Bym7hBKIfYJP0qRF/L+eMt3Yw 9fEdR03TcdrVDpSbrE7Vq7nbxnP8ZqP7vvYVgoI3SmN7V55nNJNudJQX4OHDkPMENAi/ szfPUz7W6za1PA4szEKzUv37HhHf9c0/CrJUCPPo21eBxONN894o1ga8gtVwWAR8dCb3 Gcp0hzmAVVjsMPqG/xfu++8hfah5AsSI/ku2o7TIeo5XIzydWLDh95GSue+9w5kslqrk tpqg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id jd2-20020a170903260200b00178b88d40ebsi22232488plb.51.2022.12.08.06.01.21; Thu, 08 Dec 2022 06:01:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229699AbiLHNi2 (ORCPT + 73 others); Thu, 8 Dec 2022 08:38:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbiLHNi0 (ORCPT ); Thu, 8 Dec 2022 08:38:26 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BBE48B1BF; Thu, 8 Dec 2022 05:38:25 -0800 (PST) Received: from kwepemi500014.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4NSZvw0FmfzmWL1; Thu, 8 Dec 2022 21:37:32 +0800 (CST) Received: from localhost.localdomain (10.175.112.70) by kwepemi500014.china.huawei.com (7.221.188.232) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 8 Dec 2022 21:38:22 +0800 From: Qiheng Lin To: , , , , , , CC: , , Subject: [PATCH] s390/dasd: Fix potential memleak in dasd_eckd_init() Date: Thu, 8 Dec 2022 21:38:09 +0800 Message-ID: <20221208133809.16796-1-linqiheng@huawei.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.112.70] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500014.china.huawei.com (7.221.188.232) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org `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 --- 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 5d0b9991e91a..b20ce86b97b2 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.32.0