Skip to contentSkip to conversation

btrfs: cleanup fs/btrfs/super.c::btrfs_control_ioctl()

PATCH New Américo Wang 1 participant 1 message Jan 19, 2009 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: cleanup fs/btrfs/super.c::btrfs_control_ioctl()

- Remove the unused local variable 'len';
- Check return value of kmalloc().

---

fs/btrfs/super.c +3 -2
index db9fb3b..0e9d259 100644
@@ -583,17 +583,18 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
 	struct btrfs_ioctl_vol_args *vol;
 	struct btrfs_fs_devices *fs_devices;
 	int ret = -ENOTTY;
-	int len;
 
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
 	vol = kmalloc(sizeof(*vol), GFP_KERNEL);
+	if (!vol)
+		return -ENOMEM;
+
 	if (copy_from_user(vol, (void __user *)arg, sizeof(*vol))) {
 		ret = -EFAULT;
 		goto out;
 	}
-	len = strnlen(vol->name, BTRFS_PATH_NAME_MAX);
 
 	switch (cmd) {
 	case BTRFS_IOC_SCAN_DEV: