Skip to content

Commit

Permalink
btrfs: fix warning on PTR_ERR() against NULL device at btrfs_control_…
Browse files Browse the repository at this point in the history
…ioctl()

Smatch complains about calling PTR_ERR() against a NULL pointer:

  fs/btrfs/super.c:2272 btrfs_control_ioctl() warn: passing zero to 'PTR_ERR'

Fix this by calling PTR_ERR() against the device pointer only if it
contains an error.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
Filipe Manana authored and David Sterba committed Nov 11, 2024
1 parent 80b3695 commit 2342d65
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -2254,7 +2254,10 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
device = btrfs_scan_one_device(vol->name, BLK_OPEN_READ, false);
if (IS_ERR_OR_NULL(device)) {
mutex_unlock(&uuid_mutex);
ret = PTR_ERR(device);
if (IS_ERR(device))
ret = PTR_ERR(device);
else
ret = 0;
break;
}
ret = !(device->fs_devices->num_devices ==
Expand Down

0 comments on commit 2342d65

Please sign in to comment.