All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: Don't dereference extent_mapping if NULL
@ 2010-09-29 22:20 Roel Kluin
  0 siblings, 0 replies; only message in thread
From: Roel Kluin @ 2010-09-29 22:20 UTC (permalink / raw)
  To: Chris Mason, linux-btrfs, Andrew Morton, LKML

Don't dereference em if it's NULL or an error pointer.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
I just noticed this by code analysis. It wasn't tested in any way.

 fs/btrfs/inode.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c038644..d4a37f8 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -1787,7 +1787,8 @@ static int btrfs_io_failed_hook(struct bio *failed_bio,
 
 		read_lock(&em_tree->lock);
 		em = lookup_extent_mapping(em_tree, start, failrec->len);
-		if (em->start > start || em->start + em->len < start) {
+		if (em && !IS_ERR(em) && (em->start > start ||
+					em->start + em->len < start)) {
 			free_extent_map(em);
 			em = NULL;
 		}

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

only message in thread, other threads:[~2010-09-29 22:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-29 22:20 [PATCH] Btrfs: Don't dereference extent_mapping if NULL Roel Kluin

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.