From: Lukasz Dorau Date: Thu, 27 Sep 2012 06:58:44 +0000 (+1000) Subject: fix segfaults in Detail() X-Git-Tag: mdadm-3.2.6~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aec89f63e98322a141d146a84c67b0cc2d1cd1a4;p=thirdparty%2Fmdadm.git fix segfaults in Detail() 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 Signed-off-by: NeilBrown --- diff --git a/Detail.c b/Detail.c index 85e2b89d..67ddc800 100644 --- a/Detail.c +++ b/Detail.c @@ -424,7 +424,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost, char *pre } free_mdstat(ms); - 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, @@ -575,7 +575,8 @@ This is pretty boring if (spares && brief && array.raid_disks) printf(" spares=%d", spares); if (brief && st && st->sb) st->ss->brief_detail_super(st); - st->ss->free_super(st); + if (st) + st->ss->free_super(st); if (brief > 1 && devices) printf("\n devices=%s", devices); if (brief) printf("\n");