From: Filipe David Borba Manana Date: Sun, 30 Jun 2013 11:51:45 +0000 (+0100) Subject: Btrfs-progs: add kstrdup() return value check X-Git-Tag: upstream/4.16.1~3237 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=93a96c547fa053759293390d2a393c7ab28632ab;p=platform%2Fupstream%2Fbtrfs-progs.git Btrfs-progs: add kstrdup() return value check 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 Signed-off-by: David Sterba Signed-off-by: Chris Mason --- diff --git a/volumes.c b/volumes.c index 68b4294..28b208d 100644 --- a/volumes.c +++ b/volumes.c @@ -124,6 +124,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 =