linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] btrfs: scan but don't register device on single device filesystem
@ 2023-09-15  7:05 Dan Carpenter
  2023-09-15  8:22 ` Anand Jain
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-09-15  7:05 UTC (permalink / raw)
  To: anand.jain; +Cc: linux-btrfs

Hello Anand Jain,

The patch d41f57d15a90: "btrfs: scan but don't register device on
single device filesystem" from Sep 9, 2023 (linux-next), leads to the
following Smatch static checker warning:

	fs/btrfs/volumes.c:1420 btrfs_scan_one_device()
	error: uninitialized symbol 'devt'.

fs/btrfs/volumes.c
    1411         if (!mount_arg_dev && btrfs_super_num_devices(disk_super) == 1 &&
    1412             !(btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_SEEDING)) {
    1413                 dev_t        devt;
    1414 
    1415                 ret = lookup_bdev(path, &devt);
    1416                 if (ret) {
    1417                         btrfs_warn(NULL, "lookup bdev failed for path %s: %d",
    1418                         path, ret);

Should this goto?

    1419                 }
--> 1420                 btrfs_free_stale_devices(devt, NULL);
                                                  ^^^^
Uninitialized if lookup_bdev() fails.

    1421 
    1422                 pr_debug("BTRFS (%s) skip registering single non seed device\n",
    1423                          path);
    1424                 device = NULL;
    1425                 goto free_disk_super;
    1426         }
    1427 
    1428         device = device_list_add(path, disk_super, &new_device_added);
    1429         if (!IS_ERR(device) && new_device_added)
    1430                 btrfs_free_stale_devices(device->devt, device);
    1431 
    1432 free_disk_super:
    1433         btrfs_release_disk_super(disk_super);
    1434 
    1435 error_bdev_put:
    1436         blkdev_put(bdev, NULL);
    1437 
    1438         return device;
    1439 }

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] btrfs: scan but don't register device on single device filesystem
  2023-09-15  7:05 [bug report] btrfs: scan but don't register device on single device filesystem Dan Carpenter
@ 2023-09-15  8:22 ` Anand Jain
  0 siblings, 0 replies; 2+ messages in thread
From: Anand Jain @ 2023-09-15  8:22 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-btrfs


Thanks for the report.

> 
> fs/btrfs/volumes.c
>      1411         if (!mount_arg_dev && btrfs_super_num_devices(disk_super) == 1 &&
>      1412             !(btrfs_super_flags(disk_super) & BTRFS_SUPER_FLAG_SEEDING)) {
>      1413                 dev_t        devt;
>      1414
>      1415                 ret = lookup_bdev(path, &devt);
>      1416                 if (ret) {
>      1417                         btrfs_warn(NULL, "lookup bdev failed for path %s: %d",
>      1418                         path, ret);
> 
> Should this goto?
> 
>      1419                 }
> --> 1420                 btrfs_free_stale_devices(devt, NULL);
>                                                    ^^^^
> Uninitialized if lookup_bdev() fails.

  We have to call btrfs_free_stale_devices() under the 'else' part;
  its the only one using devt.

  I have sent out the fix.

[PATCH] btrfs: fix smatch static checker warning in btrfs_scan_one_device


-Anand

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-15  8:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-15  7:05 [bug report] btrfs: scan but don't register device on single device filesystem Dan Carpenter
2023-09-15  8:22 ` Anand Jain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).