Harshavardhana
2010-Apr-08 01:24 UTC
[PATCH] fs/btrfs: Avoid possible NULL pointer dereference for fs_devices
loop is never traversed for fs_devices NULL in volumes.c
<snip>
while (fs_devices) {
.........
....... }
</snip>
Dereferencing happens right after, in this case over NULL pointer.
Signed-off-by: Harshavardhana <harsha@gluster.com>
---
fs/btrfs/volumes.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index b584e9a..e3d2e6b 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1261,7 +1261,8 @@ int btrfs_rm_device(struct btrfs_root *root, char
*device_path)
break;
fs_devices = fs_devices->seed;
}
- fs_devices->seed = device->fs_devices->seed;
+ if (fs_devices)
+ fs_devices->seed = device->fs_devices->seed;
device->fs_devices->seed = NULL;
__btrfs_close_devices(device->fs_devices);
free_fs_devices(device->fs_devices);
--
1.6.6.1
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs"
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html