File 0001-Detail-Avoid-dereferencing-some-NULL-pointers.patch of Package mdadm.1739

From c9f1cbc050eb52c058199c570864109afa0f1489 Mon Sep 17 00:00:00 2001
From: NeilBrown <neilb@suse.de>
Date: Wed, 6 Aug 2014 15:56:12 +1000
Subject: [PATCH] Detail: Avoid dereferencing some NULL pointers.

dm devices which only have a single underlying md device
will respond to md ioctls  as though they were that md device.
This can confuse mdadm and lead it to violating its segments.

So add tests for NULL where appropriate.  You might not get exactly
the right answer when you "mdadm -D" a dm device, but at least it won't
crash now.

Reported-by: Willy Weisz <Willy.Weisz@univie.ac.at>
Resolves: https://bugzilla.novell.com/show_bug.cgi?id=887821
Signed-off-by: NeilBrown <neilb@suse.de>
---
 Detail.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/Detail.c
+++ b/Detail.c
@@ -109,7 +109,7 @@ int Detail(char *dev, struct context *c)
 	st = super_by_fd(fd, &subarray);
 	if (ioctl(fd, GET_ARRAY_INFO, &array) == 0) {
 		inactive = 0;
-	} else if (errno == ENODEV) {
+	} else if (errno == ENODEV && sra) {
 		if (sra->array.major_version == -1 &&
 		    sra->array.minor_version == -1 &&
 		    sra->devs == NULL) {
@@ -475,8 +475,8 @@ int Detail(char *dev, struct context *c)
 			       (!e || (e->percent < 0 && e->percent != RESYNC_PENDING &&
 			       e->percent != RESYNC_DELAYED)) ? "" : sync_action[e->resync],
 			       larray_size ? "": ", Not Started",
-			       e->percent == RESYNC_DELAYED ? " (DELAYED)": "",
-			       e->percent == RESYNC_PENDING ? " (PENDING)": "");
+			       (e && e->percent == RESYNC_DELAYED) ? " (DELAYED)": "",
+			       (e && e->percent == RESYNC_PENDING) ? " (PENDING)": "");
 		} else if (inactive) {
 			printf("          State : inactive\n");
 		}
openSUSE Build Service is sponsored by