Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1178069lqp; Sun, 14 Apr 2024 19:08:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVckL0s2UiASN8YYe0eotplH7pGp8TjZ2MQQ6E1/dTXE1ap/6SHhKst4mjACNsBOc1ZSNMo6QqB8AUXTxsZQgvyVLYsX++vmIFYAzThpw== X-Google-Smtp-Source: AGHT+IGY4sE3IkObYyOcYsb+Xt6X0P0gkQbTPM0s7HwSn0kL/r3S9vKtwRYNdeXw3Nasu+2jZRtl X-Received: by 2002:a05:6359:418e:b0:17f:6064:e839 with SMTP id ki14-20020a056359418e00b0017f6064e839mr6019265rwc.7.1713146927114; Sun, 14 Apr 2024 19:08:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713146927; cv=pass; d=google.com; s=arc-20160816; b=rsDcwP89aABpRgECE1RJDYIveFr2dymknePhUpOC6KTrVQMRGDh2O/45vTv2CIJR5a i7gW18yiOo6JKUktKQucu+S1P8b7PKsE28BbBHQiZ5zndvfhStT53TQV84PGJIKJsuCG tVcOKJRqQwFcaD9B+MUGwEsFrCLFXGS26mnd28f/XEZjMwoo9D8sDF8zwY0mfluSGfFc 08cnPlGmm9UQnDz9P4kggQSefqlJj8aamgMuPpVdI0BuooswGR9mWNlIL44v9G/JCyD2 Xwh+JxJCM6qH7l6ouG0Cp3dsh870qdEZi17+ttoyFxYTuZbH613ndg1jgSRPJ/hkx7TA g/dA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=rvkLwjFqhiOos5shIl8g6MhDvmhhu49lydDv7RKR+cc=; fh=0xDd5MnvsSIj2Xh6KbwoUQEbt+OKJWqcD6IbkJ+Ou7g=; b=GBkmCWVhM/Ga67/ePKWvvS8YjLLcY3Z/dJjsPwZXV57ia5T/JZfOIGKabFNcQ4Wa+n KcGcadeHqSCJrzaGeOCG90jOWJOFZb0hZfSm1IDPEx0NqfRsmwFo8vR1u1pDPgQCTWcD fbPVCJga/U8ehYcmP8W07enAHyGcg8Tu5zIspLh4qiK7uZI6KI+sp0r2iXIsi9vlfD7k Jdtd+/yfAMUOdcqTYasv9DJd82c20d9LKJjK0xSn1s/+n8xGfZxFaVRi46/kl8g09Q9C NycIoJFaWIHcYaujKh6tmTwfDem6Mv6FnqL8tPukiQaDyvYV8DJXvn5gq/xGRQcoDjqM 5atA==; 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-144472-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144472-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 y21-20020a63ce15000000b005dbde0102b0si6899897pgf.288.2024.04.14.19.08.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 19:08:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144472-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-144472-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144472-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 F155EB224A5 for ; Mon, 15 Apr 2024 02:05:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DAF452262B; Mon, 15 Apr 2024 02:04:02 +0000 (UTC) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 094F0C8E9; Mon, 15 Apr 2024 02:03:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713146642; cv=none; b=koSE50xf8BfXAq3PBLNfepM0oNLnXMEVjyQ2ALl89PVUJESabKXcCRG8FlWJL4P2FzeSkmtXPtcNQkNvZ1VGiIkzayD0d1vfkPImS2fL/BjpO8WYvfyhZ4FBEv1rKCNBU6LCHRDMRO+VdAazGlOog+jOgZt7zpfsUL/nk9zDfFI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713146642; c=relaxed/simple; bh=CjdwrTInCWcUtpgHP3gj66h3ZvZGPxrLq2TqXiJ6rpw=; h=Message-ID:Date:MIME-Version:Subject:From:To:CC:References: In-Reply-To:Content-Type; b=CFdXkVf45X6HvqfMBoaiikljVpz7c0Cx7r4DEY1zWKQkvL6CtXPUMeq32xwrdzkGHTWQZonHHEucl4vPrj7qsL+4rGZx1XSZuJkDVZg3o4CVFM1jctnj7zlf4cHYQJE8RQ3jVGX+gi1Q+dVpamb42MvO/PuD6qCrTv0voRyo1Ic= 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.188 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.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VHr3m0lTzzXlSr; Mon, 15 Apr 2024 10:00:36 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 616BF140124; Mon, 15 Apr 2024 10:03:51 +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; Mon, 15 Apr 2024 10:03:51 +0800 Message-ID: Date: Mon, 15 Apr 2024 10:03:50 +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 From: Hongbo Li To: Kent Overstreet , Brian Foster CC: , , Chao Yu References: <20240412063638.2068524-1-chao@kernel.org> <9ed2e6d6-186c-4b89-9c07-4b004de6bf23@huawei.com> In-Reply-To: <9ed2e6d6-186c-4b89-9c07-4b004de6bf23@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500022.china.huawei.com (7.185.36.66) This patch fixes the issue with memory reclamation in certain case. May be we should use it! ???? On 2024/4/12 14:53, Hongbo Li wrote: > 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) >