[PATCH] fix segfaults in Detail()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

If disk has been removed, 'st' and 'info' can be NULL. It causes segfault.
'st' and 'info' should be checked against being NULL before being used.

Signed-off-by: Lukasz Dorau <lukasz.dorau@xxxxxxxxx>
 Detail.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Detail.c b/Detail.c
index 17aa516..79b1047 100644
--- a/Detail.c
+++ b/Detail.c
@@ -430,7 +430,7 @@ int Detail(char *dev, struct context *c)
-		if (st->sb && info->reshape_active) {
+		if ((st && st->sb) && (info && info->reshape_active)) {
 #if 0
 This is pretty boring
 			printf("  Reshape pos'n : %llu%s\n", (unsigned long long) info->reshape_progress<<9,
@@ -596,7 +596,8 @@ This is pretty boring
 	if (spares && c->brief && array.raid_disks) printf(" spares=%d", spares);
 	if (c->brief && st && st->sb)
-	st->ss->free_super(st);
+	if (st && st->ss)
+		st->ss->free_super(st);
 	if (c->brief > 1 && devices) printf("\n   devices=%s", devices);
 	if (c->brief)

To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[ATA RAID]     [Linux SCSI Target Infrastructure]     [Managing RAID on Linux]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device-Mapper]     [Kernel]     [Linux Books]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Photos]     [Yosemite Photos]     [Yosemite News]     [AMD 64]     [Linux Networking]

Add to Google Powered by Linux