Message ID | 20231208074629.1656356-1-linan666@huaweicloud.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp5301949vqy; Thu, 7 Dec 2023 23:47:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHDO7kN/fR7Sx52b4wJjH/yj5STIPjZKWnkY+LQ+xUuenhRFDIMG6h/S/nm0Yklb8pPLr/s X-Received: by 2002:a05:6808:3a1a:b0:3b8:b063:6bbc with SMTP id gr26-20020a0568083a1a00b003b8b0636bbcmr5170920oib.107.1702021674366; Thu, 07 Dec 2023 23:47:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702021674; cv=none; d=google.com; s=arc-20160816; b=Nagts/H2ILPsBaQZ9xEJW2JHwCNfOtLcLWxy8et6CYBCa8H7UzWu/96+4eU+aVh0NO IhmYTKzkj/Qnc6ebD8oRKt7KKP+z4kcx860+znI575E4DG0czAvmgOLi/6gbI6aFEsvc hK48Hq10gca+1odJ82/eT3cY9nTGBH6BmFSml09y2e4z5B3r1909TDexTBBroZti7xpw MzkMdT1dfK8zU218L3+WFB8ax/OmofT24el4CYhCXSzKj0Sfv0Lo3tdHE7SIGB7bs/LN MfXBEoNF94GdM9XadYC/6T25an2+BtZ/JnlqAIhYiYjVpCzMy92S/BxpyT8GTB6xmBzW QNPQ== 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=sFgZgz/uqB4Z+c4fJb7L1gvrhou0DVTUA5Zq+QncjiM=; fh=Y0RwOsiLNwDs4//+52Dq5dQnxwvpPccSb55qGMu2vCg=; b=PsZqSu3zMDM+vkS1+TPwxHMdo77vno0HiVyDYuD4Cw9OjMSQEt9YIMF8bmU2SlKcCl orycBLTMkLQjggh1lLaHhEy+j836+FVUq1jfvpUYyPuTSjOSGAQkjqYTO55CcB53BCeE VzBft2a+2PpQD5Y1qz1dqGSqgpdqAduFfc8DCzRhPtgxk/MA0oAvT714kJigIaUJW+EO y7tRX0A3Lc7HQkZm8/YKTnuddVAx+htDgzUdKWsynK2VhTAbpjArJ4Ak3Ku0EUF760TV EOwqsXXU/7iVEMxitigKNeJ42WsFTjyktrXKxEHthz+v36tvWDa3TjGOUIcK/Z59Zzjj biPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id bq5-20020a056a02044500b00573f94e8b83si1121111pgb.265.2023.12.07.23.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 23:47:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id EDA33816F0CC; Thu, 7 Dec 2023 23:47:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573325AbjLHHrk (ORCPT <rfc822;chrisfriedt@gmail.com> + 99 others); Fri, 8 Dec 2023 02:47:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1573305AbjLHHrj (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 8 Dec 2023 02:47:39 -0500 Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AF36171F for <linux-kernel@vger.kernel.org>; Thu, 7 Dec 2023 23:47:45 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4Smjsn4ZHtz4f3jHZ for <linux-kernel@vger.kernel.org>; Fri, 8 Dec 2023 15:47:41 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id BA7D21A01D2 for <linux-kernel@vger.kernel.org>; Fri, 8 Dec 2023 15:47:42 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgDn6xEcynJl8bRBDA--.44654S4; Fri, 08 Dec 2023 15:47:42 +0800 (CST) From: linan666@huaweicloud.com To: richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, linan122@huawei.com, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com Subject: [PATCH v2] ubi: block: fix memleak in ubiblock_create() Date: Fri, 8 Dec 2023 15:46:29 +0800 Message-Id: <20231208074629.1656356-1-linan666@huaweicloud.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: cCh0CgDn6xEcynJl8bRBDA--.44654S4 X-Coremail-Antispam: 1UD129KBjvdXoWrtF1kCw4ktr1ktr18Gr1DAwb_yoWDGFcE9w 4Yqrn3XrWIkrn3C34jyrWfua1jyr1UKrWkuF1fKws8ZFW7WFn7GF9xWr15Wan8ZFW7Cay5 A3WIgr12yF40qjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUba8YFVCjjxCrM7AC8VAFwI0_Gr0_Xr1l1xkIjI8I6I8E6xAIw20E Y4v20xvaj40_Wr0E3s1l1IIY67AEw4v_Jr0_Jr4l8cAvFVAK0II2c7xJM28CjxkF64kEwV A0rcxSw2x7M28EF7xvwVC0I7IYx2IY67AKxVW7JVWDJwA2z4x0Y4vE2Ix0cI8IcVCY1x02 67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I 0E14v26rxl6s0DM2vYz4IE04k24VAvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l 5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67 AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lFIxGxcIEc7Cj xVA2Y2ka0xkIwI1lw4CEc2x0rVAKj4xxMxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4 AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE 17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMI IF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_Wr1j6rW3 Jr1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcS sGvfC2KfnxnUUI43ZEXa7IU1kpnJUUUUU== X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 07 Dec 2023 23:47:50 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784699079250622024 X-GMAIL-MSGID: 1784699079250622024 |
Series |
[v2] ubi: block: fix memleak in ubiblock_create()
|
|
Commit Message
Li Nan
Dec. 8, 2023, 7:46 a.m. UTC
From: Li Nan <linan122@huawei.com> If idr_alloc() fails, dev->gd will be put after goto out_cleanup_disk in ubiblock_create(), but dev->gd has not been assigned yet at this time, and 'gd' will not be put anymore. Fix it by putting 'gd' directly. Signed-off-by: Li Nan <linan122@huawei.com> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> --- Changes in v2: - modify the description of the problem in log drivers/mtd/ubi/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
friendly ping... 在 2023/12/8 15:46, linan666@huaweicloud.com 写道: > From: Li Nan <linan122@huawei.com> > > If idr_alloc() fails, dev->gd will be put after goto out_cleanup_disk in > ubiblock_create(), but dev->gd has not been assigned yet at this time, and > 'gd' will not be put anymore. Fix it by putting 'gd' directly. > > Signed-off-by: Li Nan <linan122@huawei.com> > Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> > --- > Changes in v2: > - modify the description of the problem in log > > drivers/mtd/ubi/block.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c > index 309a42aeaa4c..654bd7372cd8 100644 > --- a/drivers/mtd/ubi/block.c > +++ b/drivers/mtd/ubi/block.c > @@ -434,7 +434,7 @@ int ubiblock_create(struct ubi_volume_info *vi) > list_del(&dev->list); > idr_remove(&ubiblock_minor_idr, gd->first_minor); > out_cleanup_disk: > - put_disk(dev->gd); > + put_disk(gd); > out_free_tags: > blk_mq_free_tag_set(&dev->tag_set); > out_free_dev:
friendly ping ... 在 2023/12/8 15:46, linan666@huaweicloud.com 写道: > From: Li Nan <linan122@huawei.com> > > If idr_alloc() fails, dev->gd will be put after goto out_cleanup_disk in > ubiblock_create(), but dev->gd has not been assigned yet at this time, and > 'gd' will not be put anymore. Fix it by putting 'gd' directly. > > Signed-off-by: Li Nan <linan122@huawei.com> > Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> > --- > Changes in v2: > - modify the description of the problem in log > > drivers/mtd/ubi/block.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c > index 309a42aeaa4c..654bd7372cd8 100644 > --- a/drivers/mtd/ubi/block.c > +++ b/drivers/mtd/ubi/block.c > @@ -434,7 +434,7 @@ int ubiblock_create(struct ubi_volume_info *vi) > list_del(&dev->list); > idr_remove(&ubiblock_minor_idr, gd->first_minor); > out_cleanup_disk: > - put_disk(dev->gd); > + put_disk(gd); > out_free_tags: > blk_mq_free_tag_set(&dev->tag_set); > out_free_dev:
diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c index 309a42aeaa4c..654bd7372cd8 100644 --- a/drivers/mtd/ubi/block.c +++ b/drivers/mtd/ubi/block.c @@ -434,7 +434,7 @@ int ubiblock_create(struct ubi_volume_info *vi) list_del(&dev->list); idr_remove(&ubiblock_minor_idr, gd->first_minor); out_cleanup_disk: - put_disk(dev->gd); + put_disk(gd); out_free_tags: blk_mq_free_tag_set(&dev->tag_set); out_free_dev: