Thread (9 messages) 9 messages, 1 author, 2008-07-08
STALE6655d

[PATCH 4/8] md: analyze_sbs(): Fix potential NULL-pointer dereference.

From: Andre Noll <hidden>
Date: 2008-03-25 20:38:30
Subsystem: software raid (multiple disks) support, the rest · Maintainers: Song Liu, Yu Kuai, Linus Torvalds

If no device in the array contains a valid super block, "freshest"
will be NULL, but we happily dereference that pointer in the subsequent
call to validate_super().

Fix it by returning early in this case.

Signed-off-by: Andre Noll <redacted>
---
 drivers/md/md.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 7943df1..bf1499c 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -2249,6 +2249,10 @@ static void analyze_sbs(mddev_t * mddev)
 			kick_rdev_from_array(rdev);
 		}
 
+	if (!freshest) {
+		printk(KERN_ERR "md: no valid devices found\n");
+		return;
+	}
 
 	super_types[mddev->major_version].
 		validate_super(mddev, freshest);
-- 
1.5.3.8
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help