Received: by 2002:ab2:7407:0:b0:1f4:b336:87c4 with SMTP id e7csp266700lqn; Fri, 12 Apr 2024 00:07:16 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX9foDZjYdNNIkbchq3OVs+4bI4fve9CynFMbKfCtE0o4UxosAMeDnvprtqUdbYSi6BJ3jXrGGi+HQgMT7JxL2x4oyq/plSTFtBG1maKg== X-Google-Smtp-Source: AGHT+IEpNnXtxiEU3CtcCLA+UV4ATtzWZgJ30mVVv7s7nM/ttgmlDaPqo4Lvp1MGWSeTxTdK3uMj X-Received: by 2002:a05:6a00:3903:b0:6ee:1737:1e43 with SMTP id fh3-20020a056a00390300b006ee17371e43mr1910265pfb.17.1712905636103; Fri, 12 Apr 2024 00:07:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712905635; cv=pass; d=google.com; s=arc-20160816; b=oUgmzNmii9Fu0aDFpd+/Wrp9EW9hcoKu2dw8T9sHdAdqM2P/3f3SU3EdBFiOIE8/zU vMJgjT4AEQQiYPOkD1awDHg0Agl3UjFbeY3bl4iM5yxgYFwJONqK1xwDiezGXfAJv5Zs LnmmELJ75QiAT/+ssRvuNDgxfZLrCjdIvLP/h+wI3cs2Df16NkVCQ1tYALXO+oqcuTff LM9bIodQnBWkGT+czcnVRosmpxOwtsGK3qd/07fFv3AQLlQyuH/oShfnKuzOC1Kjx58T N9vQfD67KtU0YFrqJOgjmfqYMQYyCnBZCW20LiPLSzxJoDuKM9EiHnBr/gZ0yN03Tvvr AXBQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=ISA7/rUfN1BkUUopZe/q/GNXrYQOAnuc8hi9+GUT910=; fh=4XmUCr7ADC7ZCzAFYOUp2HPb4CpZ5LvwJ7eynwwRsEU=; b=tzSftpe4Btjz6Z2CWR415ovxqT4TMmBWD6NtQQEPnPr5M4nrLp7OZohTOzpvuJe1TL aFvdYQLxadLsTHR4KdWcXnKKUKPyJgjkf20CzpCLBDcMVQKjlSTE+NwCT4vVxiL+luxZ 9UptSH427bCPJydhmld0Jer8ZGp7qFIYTdGqOHYTH3vvKeVZpzei4NXre6O8xJ1CkYf/ IT3/8BHN1s3p/VSJmISG0E2GHhchWnl3h4RLTtw1y27RvVqE6SNwpYH2NCms0x0LLQ0e F1/8BihXq+iqBZT8HzKt6NTPPgU9CoyRFNaq0iU4Z/AzaHZPb+9PQeLl+hjuXybSoUbp 67/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-142076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id fe7-20020a056a002f0700b006e8f9f031a4si2769068pfb.258.2024.04.12.00.07.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Apr 2024 00:07:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-142076-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; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-142076-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-142076-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com 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 813E8B23295 for ; Fri, 12 Apr 2024 06:53:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7AFFE47A53; Fri, 12 Apr 2024 06:53:07 +0000 (UTC) Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 4FA4D4652F; Fri, 12 Apr 2024 06:53:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712904787; cv=none; b=fm8HqKp7EoQGv1DGCL/WJLSvdnMPZMWomR4oGI4WBtJXGR8jWwtYgDrVMy+prUfAF9KwAZ08t8exEiBSp7/T2OVC8P1nZSWaEwgcrctdfRrVcA6UhFyGw/t4oNtAP+UpCjO56AxQiI76/YlqE3b8KI5n4C8JnEJ5OpWEwZtL5dk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712904787; c=relaxed/simple; bh=MJwKbK7opNn0X+MjquHdBM5/uyL6GuSmDDNRq43NiLU=; h=Message-ID:Date:MIME-Version:Subject:To:CC:References:From: In-Reply-To:Content-Type; b=XawMgbJ34vVK4mhGb4gSfSkwNndzqwPv0eMyMOOIFnOdY7aKlGuqVRDlQOoxfjtiADI5SY/2/Yw7UyqD6OtwIZEvXh1li7LJ4lPeGzDHFvNt4koONv8G31gEyRqWDPrEJF0SQ9zzWpvjJ1CJhtHk0189KVbZsSGoN6CCu3Z0TuI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.163]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4VG6gd2Y6Rz1xmRx; Fri, 12 Apr 2024 14:52:13 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 6F71D18001A; Fri, 12 Apr 2024 14:53:01 +0800 (CST) Received: from [10.67.111.104] (10.67.111.104) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Fri, 12 Apr 2024 14:53:01 +0800 Message-ID: <9ed2e6d6-186c-4b89-9c07-4b004de6bf23@huawei.com> Date: Fri, 12 Apr 2024 14:53:00 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] bcachefs: fix error path of __bch2_read_super() Content-Language: en-US To: Chao Yu , Kent Overstreet , Brian Foster CC: , References: <20240412063638.2068524-1-chao@kernel.org> From: Hongbo Li In-Reply-To: <20240412063638.2068524-1-chao@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500022.china.huawei.com (7.185.36.66) Reviewed-by: Hongbo Li On 2024/4/12 14:36, Chao Yu wrote: > In __bch2_read_super(), if kstrdup() fails, it needs to release memory > in sb->holder, fix to call bch2_free_super() in the error path. > > Signed-off-by: Chao Yu > --- > v2: > - add error message in error path pointed out by Hongbo Li. > fs/bcachefs/super-io.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c > index ad28e370b640..cc80d7d30b8c 100644 > --- a/fs/bcachefs/super-io.c > +++ b/fs/bcachefs/super-io.c > @@ -698,8 +698,11 @@ static int __bch2_read_super(const char *path, struct bch_opts *opts, > return -ENOMEM; > > sb->sb_name = kstrdup(path, GFP_KERNEL); > - if (!sb->sb_name) > - return -ENOMEM; > + if (!sb->sb_name) { > + ret = -ENOMEM; > + prt_printf(&err, "error allocating memory for sb_name"); > + goto err; > + } > > #ifndef __KERNEL__ > if (opt_get(*opts, direct_io) == false)