OSDN Git Service

Btrfs - Fix memory leak in btrfs_init_new_device()
authorIlya Dryomov <idryomov@gmail.com>
Sun, 6 Feb 2011 19:58:21 +0000 (19:58 +0000)
committerChris Mason <chris.mason@oracle.com>
Mon, 14 Feb 2011 21:21:31 +0000 (16:21 -0500)
Memory allocated by calling kstrdup() should be freed.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/volumes.c

index 7cad593..dadaaa8 100644 (file)
@@ -1603,12 +1603,14 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
 
        ret = find_next_devid(root, &device->devid);
        if (ret) {
+               kfree(device->name);
                kfree(device);
                goto error;
        }
 
        trans = btrfs_start_transaction(root, 0);
        if (IS_ERR(trans)) {
+               kfree(device->name);
                kfree(device);
                ret = PTR_ERR(trans);
                goto error;