Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 99ba55ad authored by Stefan Behrens's avatar Stefan Behrens Committed by David Sterba
Browse files

Btrfs: fix btrfs_ioctl_dev_info() crash on missing device



When a filesystem is mounted with the degraded option, it is
possible that some of the devices are not there.
btrfs_ioctl_dev_info() crashs in this case because the device
name is a NULL pointer. This ioctl was only used for scrub.

Signed-off-by: default avatarStefan Behrens <sbehrens@giantdisaster.de>
parent b9688bb8
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -2262,7 +2262,10 @@ static long btrfs_ioctl_dev_info(struct btrfs_root *root, void __user *arg)
	di_args->bytes_used = dev->bytes_used;
	di_args->bytes_used = dev->bytes_used;
	di_args->total_bytes = dev->total_bytes;
	di_args->total_bytes = dev->total_bytes;
	memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid));
	memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid));
	if (dev->name)
		strncpy(di_args->path, dev->name, sizeof(di_args->path));
		strncpy(di_args->path, dev->name, sizeof(di_args->path));
	else
		di_args->path[0] = '\0';


out:
out:
	if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args)))
	if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args)))