Skip to contentSkip to conversation

avoid null deref in unpin_extent_cache()

PATCH In review Dan Carpenter 2 participants 2 messages Nov 10, 2009 – Nov 11, 2009 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 avoid null deref in unpin_extent_cache()

I re-orderred the checks to avoid dereferencing "em" if it was null.

Found by smatch static checker.

regards,
dan carpenter

fs/btrfs/extent_map.c +1 -1
@@ -208,7 +208,7 @@
 	write_lock(&tree->lock);
 	em = lookup_extent_mapping(tree, start, len);
 
-	WARN_ON(em->start != start || !em);
+	WARN_ON(!em || em->start != start);
 
 	if (!em)
 		goto out;
#1 lore raw
Quoted 1 line · Dan Carpenter

I re-orderred the checks to avoid dereferencing "em" if it was null.

Thanks, I've put this into the master branch of the btrfs unstable tree.

-chris