Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan@cryspen.com>
To: oe-kbuild@lists.linux.dev, Theodore Ts'o <tytso@mit.edu>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev, linux-ext4@vger.kernel.org
Subject: [tytso-ext4:pu 13/50] fs/ext4/orphan-test.c:855 orphan_test_init() error: 'sb' dereferencing possible ERR_PTR()
Date: Fri, 13 Nov 2026 10:17:45 +0300	[thread overview]
Message-ID: <202611121755.hiQrKm5X-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git pu
head:   246d715a48c25a74ac372dda5e10d8f69f89b50a
commit: 8a129f6ffb7e1892ce3c84ba50e50f0f1049383f [13/50] ext4: add KUnit tests for fs/ext4/orphan.c
config: powerpc-randconfig-2200-20261112 (https://download.01.org/0day-ci/archive/20261112/202611121755.hiQrKm5X-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 8621950157210c1fa68f20f0614cb51310ec9dff)
smatch: v0.5.0-9187-g5189e3fb

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202611121755.hiQrKm5X-lkp@intel.com/

smatch warnings:
fs/ext4/orphan-test.c:855 orphan_test_init() error: 'sb' dereferencing possible ERR_PTR()

vim +/sb +855 fs/ext4/orphan-test.c

8a129f6ffb7e18 Theodore Ts'o 2026-11-06   812  KUNIT_DEFINE_ACTION_WRAPPER(orphan_test_cleanup_action, orphan_test_cleanup,
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   813  			    struct orphan_test_ctx *);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   814  
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   815  static int orphan_test_init(struct kunit *test)
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   816  {
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   817  	struct orphan_test_ctx *ctx;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   818  	struct fs_context *fc;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   819  	struct super_block *sb;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   820  	struct ext4_sb_info *sbi;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   821  	struct inode *root_inode;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   822  	ext4_group_t g;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   823  	unsigned int bit;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   824  	int err;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   825  
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   826  	ctx = kzalloc_obj(*ctx);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   827  	KUNIT_ASSERT_NOT_NULL(test, ctx);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   828  	test->priv = ctx;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   829  
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   830  	ctx->bdev.bd_stats = alloc_percpu(struct disk_stats);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   831  	if (!ctx->bdev.bd_stats) {
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   832  		kfree(ctx);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   833  		KUNIT_FAIL_AND_ABORT(test, "failed to alloc bd_stats");
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   834  	}
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   835  
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   836  	fc = fs_context_for_mount(&orphan_test_fs_type, 0);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   837  	if (IS_ERR(fc)) {
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   838  		err = PTR_ERR(fc);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   839  		free_percpu(ctx->bdev.bd_stats);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   840  		kfree(ctx);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   841  		KUNIT_ASSERT_EQ(test, err, 0);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   842  	}
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   843  	sb = sget_fc(fc, NULL, set_anon_super_fc);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   844  	put_fs_context(fc);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   845  	if (IS_ERR(sb)) {
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   846  		err = PTR_ERR(sb);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   847  		free_percpu(ctx->bdev.bd_stats);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   848  		kfree(ctx);
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   849  		KUNIT_ASSERT_EQ(test, err, 0);

Of course err will never be zero, but this condition is an unreadable
way to ASSERT() failure...  Smatch tends to ignore these sorts of
asserts where a complicated condition ends up being always true on
the basis of, "I probably parsed this wrong if people are checking it".

8a129f6ffb7e18 Theodore Ts'o 2026-11-06   850  	}
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   851  	ctx->sb = sb;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   852  	sbi = &ctx->sbi;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   853  
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   854  	sbi->s_sb = sb;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06  @855  	sb->s_fs_info = sbi;
                                                ^^^^^^^^^^^^^
Warning.

8a129f6ffb7e18 Theodore Ts'o 2026-11-06   856  	sb->s_op = &orphan_test_sops;
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   857  #ifdef CONFIG_QUOTA
8a129f6ffb7e18 Theodore Ts'o 2026-11-06   858  	sb->dq_op = &orphan_test_qops;

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


                 reply	other threads:[~2026-11-13  7:17 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202611121755.hiQrKm5X-lkp@intel.com \
    --to=dan@cryspen.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox