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 7cad59353b09c4fdf0cb80072e109bf0f9db7165..dadaaa8005c8227723c87ff01043040f9a458aa1 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;