Skip to content

Commit

Permalink
fs: btrfs: volumes.c: Fix for possible null pointer dereference
Browse files Browse the repository at this point in the history
There is otherwise a risk of a possible null pointer dereference.

Was largely found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <[email protected]>
Signed-off-by: Chris Mason <[email protected]>
  • Loading branch information
Rickard Strandqvist authored and masoncl committed Jun 10, 2014
1 parent c189544 commit 8321cf2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1690,11 +1690,12 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
struct btrfs_fs_devices *fs_devices;
fs_devices = root->fs_info->fs_devices;
while (fs_devices) {
if (fs_devices->seed == cur_devices)
if (fs_devices->seed == cur_devices) {
fs_devices->seed = cur_devices->seed;
break;
}
fs_devices = fs_devices->seed;
}
fs_devices->seed = cur_devices->seed;
cur_devices->seed = NULL;
lock_chunks(root);
__btrfs_close_devices(cur_devices);
Expand Down

0 comments on commit 8321cf2

Please sign in to comment.