From: Jonathan Liu Date: Tue, 12 Apr 2011 08:28:01 +0000 (+1000) Subject: Monitor: avoid NULL dereference with 0.90 metadata X-Git-Tag: mdadm-3.2.2~100 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4019ad07013a5d8618b867f724d1c4a13c5cb05d;p=thirdparty%2Fmdadm.git Monitor: avoid NULL dereference with 0.90 metadata 0.90 array do not report the metadata type in /proc/mdstat, so we cannot assume that mse->metadata_version is non-NULL. So add an appropriate check. This adds an additional check missed by commit eb28e119b03fd5149886ed516fa4bb006ad3602e. Signed-off-by: NeilBrown --- diff --git a/Monitor.c b/Monitor.c index a3ea7247..55aebeba 100644 --- a/Monitor.c +++ b/Monitor.c @@ -577,7 +577,8 @@ static int check_array(struct state *st, struct mdstat_ent *mdstat, info[i].major = info[i].minor = 0; } - if (strncmp(mse->metadata_version, "external:", 9) == 0 && + if (mse->metadata_version && + strncmp(mse->metadata_version, "external:", 9) == 0 && is_subarray(mse->metadata_version+9)) st->parent_dev = devname2devnum(mse->metadata_version+10);