Skip to contentSkip to conversation

Btrfs: check return of kmalloc in btrfs_control_ioctl

PATCH New Shen Feng 1 participant 1 message Dec 29, 2008 Btrfs file system

lore
Share & tools
lore

Shen Feng

author
#0 lore raw

PATCH 1/1 Btrfs: check return of kmalloc in btrfs_control_ioctl

The memory allocated by kmalloc should be checked before using it.

---
 fs/btrfs/super.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
fs/btrfs/super.c +2 -0
index 84c3b66..d0e8dce 100644
@@ -590,6 +590,8 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd,
 	int len;
 
 	vol = kmalloc(sizeof(*vol), GFP_KERNEL);
+	if (!vol)
+		return -ENOMEM;
 	if (copy_from_user(vol, (void __user *)arg, sizeof(*vol))) {
 		ret = -EFAULT;
 		goto out;
Signature · 1 line
1.6.0.6