summaryrefslogtreecommitdiff
path: root/volumes.c
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@gmail.com>2013-06-30 12:51:45 +0100
committerDavid Sterba <dsterba@suse.cz>2013-08-09 14:32:32 +0200
commit93a96c547fa053759293390d2a393c7ab28632ab (patch)
treecf202637782c9ba3ce1e9947471789faca7f81f5 /volumes.c
parentbe96777126d283773e4397278a5662d90676ab88 (diff)
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 <fdmanana@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'volumes.c')
-rw-r--r--volumes.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/volumes.c b/volumes.c
index 68b4294c..28b208de 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 =