From: Rickard Strandqvist Date: Thu, 22 May 2014 20:43:43 +0000 (+0200) Subject: fs: btrfs: volumes.c: Fix for possible null pointer dereference X-Git-Tag: v4.9.8~6070^2~66 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8321cf2596d283821acc466377c2b85bcd3422b7;p=platform%2Fkernel%2Flinux-rpi3.git fs: btrfs: volumes.c: Fix for possible null pointer dereference 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 Signed-off-by: Chris Mason --- diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 7d725a9..ffeed6d 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -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);