Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4950759rdb; Fri, 29 Dec 2023 22:33:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGWazXUDTMhH/WkRf7PDTQNrsc5xDcpZYKdKyLSH6iJ9gHgUGzyXfmzdcN7OIKNoYr5itzR X-Received: by 2002:a05:6871:69e:b0:203:f307:ae12 with SMTP id l30-20020a056871069e00b00203f307ae12mr15000423oao.104.1703918034810; Fri, 29 Dec 2023 22:33:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703918034; cv=none; d=google.com; s=arc-20160816; b=hhVIdR1UVEYKBYJpg/8pqKGCIq43AfvM9XZQZUkrjkRoOJy8IRy1WMhUwN5WMHFcIT Ploaei7l5cX9OF02PQKlmdlbCwf6y9BP77IHneHC7PIX5QJHOBrtg/7km0srlKD8h0Jv 5m4yBYOOlVg6JPPRzgt3WKVkkBBmVwVk5bLEThbetBqJ1D2XnovvYIlupZJL1NdlgAU7 Hi4w5x2jK3/6ycTBM/2BSSC1VlennNqh5bi+t41bqtbAhP1CID8Boh4tNNzIDAQ4odHV ar33XqQHiLd1GvSlghrfHC75MtNFVJPluIg92qM+TBSScwTzeoS2MWBSC16hvvh5rTUd hX6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id; bh=XNJVH9TJBwYxgraaWWsEQjLbvRvtFe47ux/m4AQS9CM=; fh=5zY2KqFOKK6DG+90p+U9o7eE7VJpreljVhAsLRK9uPU=; b=M+rB/pUpPNoYnqwGEU6YW6LGCd9KbKswtDZ7LbeX24/AzTGLmHKxRAh5id1jVWfeWi LJnGNiraW+2L1priGDtH5MBxu15m16UHuE46qELPfnCOITUrhBHDp0/lS7c2PjQpwkXa Ci1y4WXt8hXqc+yVyjPbqMR0Iaqbkw3sRT/nn/zOPGeqVzwDi92gE/KPa1G575gBi946 7B0WNDqN23tchp8X4rHcP2a0Np/NtyMj+xtgsReN7Mgp8rB1FUIfA9lrO6n2NR8B3DQt EsgrupgNsgyvKqi8iaejtdpvCKFTbwGQEvr0pwN0zCn/n5RP7oMhgxzStVrB/9e6QfHd p5ZA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13343-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13343-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id by33-20020a056a0205a100b005cddb743bc7si12573481pgb.709.2023.12.29.22.33.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 22:33:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13343-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13343-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13343-linux.lists.archive=gmail.com@vger.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 24F1CB2160F for ; Sat, 30 Dec 2023 06:33:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4400B23A5; Sat, 30 Dec 2023 06:33:46 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from dggsgout11.his.huawei.com (unknown [45.249.212.51]) (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 EC1661FAF for ; Sat, 30 Dec 2023 06:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4T2C9x6wNxz4f3jMC for ; Sat, 30 Dec 2023 14:33:25 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.75]) by mail.maildlp.com (Postfix) with ESMTP id 7A02E1A017D for ; Sat, 30 Dec 2023 14:33:31 +0800 (CST) Received: from [10.174.179.247] (unknown [10.174.179.247]) by APP2 (Coremail) with SMTP id Syh0CgAnyki6uY9lCnOaFA--.42895S3; Sat, 30 Dec 2023 14:33:31 +0800 (CST) Message-ID: <9a4da75c-b6cf-0ee4-ef3b-5e19af6cb144@huaweicloud.com> Date: Sat, 30 Dec 2023 14:33:30 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH v2] ubi: block: fix memleak in ubiblock_create() To: linan666@huaweicloud.com, richard@nod.at, miquel.raynal@bootlin.com, vigneshr@ti.com Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, yukuai3@huawei.com, yi.zhang@huawei.com, houtao1@huawei.com, yangerkun@huawei.com References: <20231208074629.1656356-1-linan666@huaweicloud.com> From: Li Nan In-Reply-To: <20231208074629.1656356-1-linan666@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID:Syh0CgAnyki6uY9lCnOaFA--.42895S3 X-Coremail-Antispam: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VU1c4S5UUUUU== X-CM-SenderInfo: polqt0awwwqx5xdzvxpfor3voofrz/ friendly ping... 在 2023/12/8 15:46, linan666@huaweicloud.com 写道: > From: Li Nan > > 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 > Reviewed-by: Zhihao Cheng > --- > 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: -- Thanks, Nan