Skip to content

Commit 2342d65

Browse files
fdmananakdave
authored andcommitted
btrfs: fix warning on PTR_ERR() against NULL device at btrfs_control_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 <[email protected]> Signed-off-by: Filipe Manana <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 80b3695 commit 2342d65

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/btrfs/super.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2254,7 +2254,10 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
22542254
device = btrfs_scan_one_device(vol->name, BLK_OPEN_READ, false);
22552255
if (IS_ERR_OR_NULL(device)) {
22562256
mutex_unlock(&uuid_mutex);
2257-
ret = PTR_ERR(device);
2257+
if (IS_ERR(device))
2258+
ret = PTR_ERR(device);
2259+
else
2260+
ret = 0;
22582261
break;
22592262
}
22602263
ret = !(device->fs_devices->num_devices ==

0 commit comments

Comments
 (0)