diff mbox

Btrfs: Don't dereference extent_mapping if NULL

Message ID 4CA3BBAD.8080207@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Roel Kluin Sept. 29, 2010, 10:20 p.m. UTC
None
diff mbox

Patch

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;
 		}