From: Neil Brown Date: Mon, 26 May 2008 23:18:34 +0000 (+1000) Subject: Remember to close directories when we are finished with them. X-Git-Tag: devel~28 X-Git-Url: http://git.ipfire.org/?p=thirdparty%2Fmdadm.git;a=commitdiff_plain;h=355726fa014fb9d656e6af92f0305e55af58de09 Remember to close directories when we are finished with them. --- diff --git a/sysfs.c b/sysfs.c index 87d314c1..ea7d52f6 100644 --- a/sysfs.c +++ b/sysfs.c @@ -92,7 +92,7 @@ struct mdinfo *sysfs_read(int fd, int devnum, unsigned long options) char *dbase; struct mdinfo *sra; struct mdinfo *dev; - DIR *dir; + DIR *dir = NULL; struct dirent *de; sra = malloc(sizeof(*sra)); @@ -253,9 +253,12 @@ struct mdinfo *sysfs_read(int fd, int devnum, unsigned long options) dev->errors = strtoul(buf, NULL, 0); } } + closedir(dir); return sra; abort: + if (dir) + closedir(dir); sysfs_free(sra); return NULL; } diff --git a/util.c b/util.c index 8e4e60d3..d026c302 100644 --- a/util.c +++ b/util.c @@ -982,6 +982,7 @@ int open_container(int fd) return dfd; } } + closedir(dir); return -1; }