All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs/btrfs: Avoid possible NULL pointer dereference for fs_devices
@ 2010-04-08  1:24 Harshavardhana
  0 siblings, 0 replies; only message in thread
From: Harshavardhana @ 2010-04-08  1:24 UTC (permalink / raw)
  To: linux-btrfs

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


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2010-04-08  1:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-08  1:24 [PATCH] fs/btrfs: Avoid possible NULL pointer dereference for fs_devices Harshavardhana

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.