[PATCH 2/3] Btrfs-progs: add kstrdup() return value check

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When allocating a btrfs_device structure, device_list_add()
in volumes.c was not checking if the call to duplicate the
label string succeeded or not.

Signed-off-by: Filipe David Borba Manana <fdmanana@xxxxxxxxx>
---
 volumes.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/volumes.c b/volumes.c
index d6f81f8..ea1d401 100644
--- a/volumes.c
+++ b/volumes.c
@@ -125,6 +125,11 @@ static int device_list_add(const char *path,
 			return -ENOMEM;
 		}
 		device->label = kstrdup(disk_super->label, GFP_NOFS);
+		if (!device->label) {
+			kfree(device->name);
+			kfree(device);
+			return -ENOMEM;
+		}
 		device->total_devs = btrfs_super_num_devices(disk_super);
 		device->super_bytes_used = btrfs_super_bytes_used(disk_super);
 		device->total_bytes =
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux