Skip to content

Commit

Permalink
btrfs: test for valid bdev before kobj removal in btrfs_rm_device
Browse files Browse the repository at this point in the history
commit 99994cd btrfs: dev delete should remove sysfs entry
added a btrfs_kobj_rm_device, which dereferences device->bdev...
right after we check whether device->bdev might be NULL.

I don't honestly know if it's possible to have a NULL device->bdev
here, but assuming that it is (given the test), we need to move
the kobject removal to be under that test.

(Coverity spotted this)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <clm@fb.com>
  • Loading branch information
Eric Sandeen authored and Chris Mason committed Jul 19, 2014
1 parent 98ce2de commit 0bfaa9c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1680,11 +1680,11 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
if (device->bdev == root->fs_info->fs_devices->latest_bdev)
root->fs_info->fs_devices->latest_bdev = next_device->bdev;

if (device->bdev)
if (device->bdev) {
device->fs_devices->open_devices--;

/* remove sysfs entry */
btrfs_kobj_rm_device(root->fs_info, device);
/* remove sysfs entry */
btrfs_kobj_rm_device(root->fs_info, device);
}

call_rcu(&device->rcu, free_device);

Expand Down

0 comments on commit 0bfaa9c

Please sign in to comment.