From: Neil Brown Date: Fri, 16 Jun 2006 00:26:12 +0000 (+1000) Subject: Fix memory leak in monitor mode X-Git-Tag: mdadm-2.5.1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eed35d6661e9e53b7ec6d1312baa41bcd4d631ca;p=thirdparty%2Fmdadm.git Fix memory leak in monitor mode When rescanning /dev, we didn't free the old list. Also don't search for device with a number of 0,0 Signed-off-by: Neil Brown --- diff --git a/util.c b/util.c index 5b994d6a..d54d4452 100644 --- a/util.c +++ b/util.c @@ -416,10 +416,23 @@ char *map_dev(int major, int minor, int create) struct devmap *p; char *std = NULL, *nonstd=NULL; int did_check = 0; + + if (major == 0 && minor == 0) { + if (!create) + return NULL; + else + return "0:0"; + } retry: if (!devlist_ready) { char *dev = "/dev"; struct stat stb; + while(devlist) { + struct devmap *d = devlist; + devlist = d->next; + free(d->name); + free(d); + } if (lstat(dev, &stb)==0 && S_ISLNK(stb.st_mode)) dev = "/dev/."; diff --git a/xlate.h b/xlate.h new file mode 100644 index 00000000..e69de29b