* [bug report] btrfs: abort transaction in the process_one_buffer() log tree walk callback
@ 2025-08-15 6:49 Dan Carpenter
2025-08-15 8:28 ` Filipe Manana
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2025-08-15 6:49 UTC (permalink / raw)
To: Filipe Manana; +Cc: linux-btrfs
Hello Filipe Manana,
This is a semi-automatic email about new static checker warnings.
Commit f6f79221b128 ("btrfs: abort transaction in the
process_one_buffer() log tree walk callback") from Jul 16, 2025,
leads to the following Smatch complaint:
fs/btrfs/tree-log.c:377 process_one_buffer() warn: variable dereferenced before check 'trans' (see line 375)
fs/btrfs/tree-log.c:388 process_one_buffer() warn: variable dereferenced before check 'trans' (see line 375)
fs/btrfs/tree-log.c
374 if (wc->pin) {
375 ret = btrfs_pin_extent_for_log_replay(trans, eb);
^^^^^
The patch adds a dereference
376 if (ret) {
377 if (trans)
^^^^^
And also this check which is too late.
378 btrfs_abort_transaction(trans, ret);
379 else
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [bug report] btrfs: abort transaction in the process_one_buffer() log tree walk callback
2025-08-15 6:49 [bug report] btrfs: abort transaction in the process_one_buffer() log tree walk callback Dan Carpenter
@ 2025-08-15 8:28 ` Filipe Manana
2025-08-15 9:13 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Filipe Manana @ 2025-08-15 8:28 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Filipe Manana, linux-btrfs
On Fri, Aug 15, 2025 at 7:50 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> Hello Filipe Manana,
>
> This is a semi-automatic email about new static checker warnings.
>
> Commit f6f79221b128 ("btrfs: abort transaction in the
> process_one_buffer() log tree walk callback") from Jul 16, 2025,
> leads to the following Smatch complaint:
>
> fs/btrfs/tree-log.c:377 process_one_buffer() warn: variable dereferenced before check 'trans' (see line 375)
> fs/btrfs/tree-log.c:388 process_one_buffer() warn: variable dereferenced before check 'trans' (see line 375)
>
> fs/btrfs/tree-log.c
> 374 if (wc->pin) {
> 375 ret = btrfs_pin_extent_for_log_replay(trans, eb);
> ^^^^^
> The patch adds a dereference
False alarm. This already happened before that patch, we didn't check
if wc->trans was NULL before calling
btrfs_pin_extent_for_log_replay(), and that's fine because if wc->pin
is true then trans is not NULL.
Thanks.
>
> 376 if (ret) {
> 377 if (trans)
> ^^^^^
> And also this check which is too late.
>
> 378 btrfs_abort_transaction(trans, ret);
> 379 else
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [bug report] btrfs: abort transaction in the process_one_buffer() log tree walk callback
2025-08-15 8:28 ` Filipe Manana
@ 2025-08-15 9:13 ` Dan Carpenter
2025-08-15 11:28 ` Filipe Manana
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2025-08-15 9:13 UTC (permalink / raw)
To: Filipe Manana; +Cc: Filipe Manana, linux-btrfs
On Fri, Aug 15, 2025 at 09:28:34AM +0100, Filipe Manana wrote:
> On Fri, Aug 15, 2025 at 7:50 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > Hello Filipe Manana,
> >
> > This is a semi-automatic email about new static checker warnings.
> >
> > Commit f6f79221b128 ("btrfs: abort transaction in the
> > process_one_buffer() log tree walk callback") from Jul 16, 2025,
> > leads to the following Smatch complaint:
> >
> > fs/btrfs/tree-log.c:377 process_one_buffer() warn: variable dereferenced before check 'trans' (see line 375)
> > fs/btrfs/tree-log.c:388 process_one_buffer() warn: variable dereferenced before check 'trans' (see line 375)
> >
> > fs/btrfs/tree-log.c
> > 374 if (wc->pin) {
> > 375 ret = btrfs_pin_extent_for_log_replay(trans, eb);
> > ^^^^^
> > The patch adds a dereference
>
> False alarm. This already happened before that patch, we didn't check
> if wc->trans was NULL before calling
> btrfs_pin_extent_for_log_replay(), and that's fine because if wc->pin
> is true then trans is not NULL.
>
To be honest, the deleting the NULL check is the most common way to fix
a "pointless NULL check after a dereference" warning...
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [bug report] btrfs: abort transaction in the process_one_buffer() log tree walk callback
2025-08-15 9:13 ` Dan Carpenter
@ 2025-08-15 11:28 ` Filipe Manana
0 siblings, 0 replies; 4+ messages in thread
From: Filipe Manana @ 2025-08-15 11:28 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Filipe Manana, linux-btrfs
On Fri, Aug 15, 2025 at 10:13 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> On Fri, Aug 15, 2025 at 09:28:34AM +0100, Filipe Manana wrote:
> > On Fri, Aug 15, 2025 at 7:50 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
> > >
> > > Hello Filipe Manana,
> > >
> > > This is a semi-automatic email about new static checker warnings.
> > >
> > > Commit f6f79221b128 ("btrfs: abort transaction in the
> > > process_one_buffer() log tree walk callback") from Jul 16, 2025,
> > > leads to the following Smatch complaint:
> > >
> > > fs/btrfs/tree-log.c:377 process_one_buffer() warn: variable dereferenced before check 'trans' (see line 375)
> > > fs/btrfs/tree-log.c:388 process_one_buffer() warn: variable dereferenced before check 'trans' (see line 375)
> > >
> > > fs/btrfs/tree-log.c
> > > 374 if (wc->pin) {
> > > 375 ret = btrfs_pin_extent_for_log_replay(trans, eb);
> > > ^^^^^
> > > The patch adds a dereference
> >
> > False alarm. This already happened before that patch, we didn't check
> > if wc->trans was NULL before calling
> > btrfs_pin_extent_for_log_replay(), and that's fine because if wc->pin
> > is true then trans is not NULL.
> >
>
> To be honest, the deleting the NULL check is the most common way to fix
> a "pointless NULL check after a dereference" warning...
Yes, the NULL checks can be removed inside that if block.
I sent earlier a patch to remove them and it will later be folded into
that commit:
https://lore.kernel.org/linux-btrfs/4629b5fcab544101e9b6f935a7856428abe2f56d.1755248327.git.fdmanana@suse.com/
>
> regards,
> dan carpenter
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-15 11:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-15 6:49 [bug report] btrfs: abort transaction in the process_one_buffer() log tree walk callback Dan Carpenter
2025-08-15 8:28 ` Filipe Manana
2025-08-15 9:13 ` Dan Carpenter
2025-08-15 11:28 ` Filipe Manana
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.