All of lore.kernel.org
 help / color / mirror / Atom feed
From: Harshavardhana <harsha@gluster.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH] fs/btrfs: Avoid possible NULL pointer dereference for fs_devices
Date: Wed,  7 Apr 2010 18:24:04 -0700	[thread overview]
Message-ID: <1270689844-8404-1-git-send-email-harsha@gluster.com> (raw)

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


                 reply	other threads:[~2010-04-08  1:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1270689844-8404-1-git-send-email-harsha@gluster.com \
    --to=harsha@gluster.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.