Message ID | 20221025084704.3922-1-zeming@nfschina.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp890823wru; Tue, 25 Oct 2022 02:05:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6yJvyf7c5I8M9jlEvfY5n9/7/XX3wSNnv4+EE7LaWkWqEuWmJP16k/xLXF+JrEl/DhuWuV X-Received: by 2002:a17:907:2cca:b0:78d:ec48:ac29 with SMTP id hg10-20020a1709072cca00b0078dec48ac29mr31277937ejc.114.1666688737154; Tue, 25 Oct 2022 02:05:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666688737; cv=none; d=google.com; s=arc-20160816; b=Lta+W68wGoacs5RInFLN+yOORXW/Xu/NpyJQ+43AnRLcGmsg3NtjHKFGRPa5g3Q2Eu U78ENEz+9xp5bfjXpz2ThML7UzmZcDzCmoMhX4DXkaVsda2ypkzqfNK0w2TO9zCrZHFs oR5KSf6gMfXvweWDsN/tcw1Qfotjvn2ooMrOquYAZWh9wJp2EhJyGCbe1B+O6xY3xegT yVvQ8AqPUrg/7Hl6BqVQHBKMVbjph4E2Bb3OndM0ZnUnK4CfhP2OsfDoQQuvlJCTudEk q3KvylEMABpTiHOAVuAmFqtj1OUzNqgjka+gx0JXGusX5Xg5sAOU/zOuf8aLs1iMgicQ WjPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=HXcMX6eNhgCw3ig3qgOtZowgVXeOWn1U5NqqNzlkzv4=; b=D2MBDHfvtxYhSEvE2EOeSPbTsU6zvfhhnmyhxYlI83Ui/ymoBM/+BV3d/tVym4wtRa p0I4jjVlaCPuTk69v6Zm1xARPauZv4mDkCLJpob99+/o0n3B+1wvPl9whhXqIfl7rdK8 DVXb95O1p2lesEX7qJJXKn1R9uuT73sxJAH+4bo74w1Tj3trjh+Uq9FJTrX6XwZyhB3I SB0Y/KcNDA538NAqxgyBpzLHFZpsOnCAiWds4UJhG29k+Nv2xZRDF4fOlN2D7HJNzpj/ 8VEje421Kx5gT95jMBg1aZX93DbcqTH3mE/ciL5YYga92hNzPdJPrQe5pTofoj1jNtMN flMw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gs35-20020a1709072d2300b00780328a0868si2427664ejc.110.2022.10.25.02.05.11; Tue, 25 Oct 2022 02:05:37 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231345AbiJYIrU (ORCPT <rfc822;lucius.rs.storz@gmail.com> + 99 others); Tue, 25 Oct 2022 04:47:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbiJYIrS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 25 Oct 2022 04:47:18 -0400 Received: from mail.nfschina.com (unknown [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A303A2F034; Tue, 25 Oct 2022 01:47:16 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id B12871E80C82; Tue, 25 Oct 2022 16:45:54 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iADYo2F-nhmW; Tue, 25 Oct 2022 16:45:52 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 1AEC41E80C80; Tue, 25 Oct 2022 16:45:52 +0800 (CST) From: Li zeming <zeming@nfschina.com> To: willy@infradead.org, jlayton@kernel.org, song@kernel.org, bvanassche@acm.org, neilb@suse.de Cc: reiserfs-devel@vger.kernel.org, linux-kernel@vger.kernel.org, Li zeming <zeming@nfschina.com> Subject: [PATCH] reiserfs: journal: Increase jl pointer check Date: Tue, 25 Oct 2022 16:47:04 +0800 Message-Id: <20221025084704.3922-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747649809151412562?= X-GMAIL-MSGID: =?utf-8?q?1747649809151412562?= |
Series |
reiserfs: journal: Increase jl pointer check
|
|
Commit Message
Li zeming
Oct. 25, 2022, 8:47 a.m. UTC
If kzalloc fails to allocate the jl pointer, NULL is returned directly.
Signed-off-by: Li zeming <zeming@nfschina.com>
---
fs/reiserfs/journal.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On Tue, 25 Oct 2022, Li zeming wrote: > If kzalloc fails to allocate the jl pointer, NULL is returned directly. > > Signed-off-by: Li zeming <zeming@nfschina.com> > --- > fs/reiserfs/journal.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c > index 94addfcefede..d64e9de126c1 100644 > --- a/fs/reiserfs/journal.c > +++ b/fs/reiserfs/journal.c > @@ -2569,6 +2569,9 @@ static struct reiserfs_journal_list *alloc_journal_list(struct super_block *s) > struct reiserfs_journal_list *jl; > jl = kzalloc(sizeof(struct reiserfs_journal_list), > GFP_NOFS | __GFP_NOFAIL); > + if (!jl) > + return NULL; > + What do you think the __GFP_NOFAIL flag might mean? NeilBrown > INIT_LIST_HEAD(&jl->j_list); > INIT_LIST_HEAD(&jl->j_working_list); > INIT_LIST_HEAD(&jl->j_tail_bh_list); > -- > 2.18.2 > >
I'm sorry, I think __GFP_NOFAIL should be like this: The __GFP_NOFAIL flag will cause memory to be allocated an infinite number of times until the allocation is successful, but it is best to use it only for very necessary code, and try not to use it. I'm not sure alloc_journal_list function is a very important function here. If it is, this patch ignores it and does not consider it anymore __GFP_NOFAIL allocatiIon problem.
On Wed, 26 Oct 2022, Li zeming wrote: > I'm sorry, I think __GFP_NOFAIL should be like this: > > The __GFP_NOFAIL flag will cause memory to be allocated an infinite > number of times until the allocation is successful, but it is best to > use it only for very necessary code, and try not to use it. I agree with that. But you didn't try not to use it - you left it there in the code. Had you removed the flag as well, then your patch would have made a bit more sense. However you would then need to explain why it is safe to return NULL from alloc_journal_list(). Are you sure callers don't try to dereference the pointer? > > I'm not sure alloc_journal_list function is a very important function > here. If it is, this patch ignores it and does not consider it anymore > __GFP_NOFAIL allocatiIon problem. > > You are correct that the function isn't very important, but that is because reiserfs itself isn't very important. You might not have noticed, but in the reiserfs Kconfig file it says: Reiserfs is deprecated and scheduled to be removed from the kernel in 2025. If you are still using it, please migrate to another filesystem or tell us your usecase for reiserfs. So it will still be around for a few years, but there isn't much point with small clean-ups like this as hardly anyone uses the code, and in a few years it won't be in mainline Linux at all. Thanks, NeilBrown
many thanks for your reply. I think I should do something more meaningful .
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index 94addfcefede..d64e9de126c1 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c @@ -2569,6 +2569,9 @@ static struct reiserfs_journal_list *alloc_journal_list(struct super_block *s) struct reiserfs_journal_list *jl; jl = kzalloc(sizeof(struct reiserfs_journal_list), GFP_NOFS | __GFP_NOFAIL); + if (!jl) + return NULL; + INIT_LIST_HEAD(&jl->j_list); INIT_LIST_HEAD(&jl->j_working_list); INIT_LIST_HEAD(&jl->j_tail_bh_list);