]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
fix segfaults in Detail()
authorLukasz Dorau <lukasz.dorau@intel.com>
Thu, 20 Sep 2012 01:06:25 +0000 (11:06 +1000)
committerNeilBrown <neilb@suse.de>
Thu, 20 Sep 2012 01:06:25 +0000 (11:06 +1000)
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@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Detail.c

index 17aa5162a5528746f0705ff7af90eab2ad5bc002..f633d9365cc392d0d0f91284c6364cedcf1292d7 100644 (file)
--- a/Detail.c
+++ b/Detail.c
@@ -430,7 +430,7 @@ int Detail(char *dev, struct context *c)
                }
                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,
@@ -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->brief_detail_super(st);
-       st->ss->free_super(st);
+       if (st)
+               st->ss->free_super(st);
 
        if (c->brief > 1 && devices) printf("\n   devices=%s", devices);
        if (c->brief)