On Wed, Mar 12, 2025 at 11:32:51AM +0300, Dan Carpenter wrote:
> Hello Kent Overstreet,
>
> This is a semi-automatic email about new static checker warnings.
>
> Commit 76966dbfa9eb ("bcachefs: Improve locking in
> __bch2_set_nr_journal_buckets()") from Feb 11, 2023, leads to the
> following Smatch complaint:
>
> fs/bcachefs/journal.c:1184 bch2_set_nr_journal_buckets_iter() error: we
> previously assumed 'c' could be null (see line 1153)
> fs/bcachefs/journal.c:1187 bch2_set_nr_journal_buckets_iter() warn: variable
> dereferenced before check 'c' (see line 1184)
>
> fs/bcachefs/journal.c
> 1183
> 1184 bch2_write_super(c);
> ^
> Unchecked dereference
>
> 1185
> 1186 /* Commit: */
> 1187 if (c)
> ^
> Checked too late
>
> 1188 spin_lock(&c->journal.lock);
> 1189
>
> regards,
> dan carpenter
that code is just weird, it also depends on the new_fs param
(It's got to work for a bunch of different bringup situations, so
they've all got automated tests).