From: Stefan Behrens Date: Mon, 19 Mar 2012 15:17:22 +0000 (+0100) Subject: Btrfs: fix btrfs_ioctl_dev_info() crash on missing device X-Git-Tag: upstream/snapshot3+hdmi~7556^2~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99ba55ad696944b37d5557bc5b4816890854fdb9;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git 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: Stefan Behrens --- diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 18cc23d..14f8e1f 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -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->total_bytes = dev->total_bytes; memcpy(di_args->uuid, dev->uuid, sizeof(di_args->uuid)); - strncpy(di_args->path, dev->name, sizeof(di_args->path)); + if (dev->name) + strncpy(di_args->path, dev->name, sizeof(di_args->path)); + else + di_args->path[0] = '\0'; out: if (ret == 0 && copy_to_user(arg, di_args, sizeof(*di_args)))