From: NeilBrown Date: Tue, 4 Nov 2008 09:56:11 +0000 (+1100) Subject: Abort sysfs_read early if no device found. X-Git-Tag: mdadm-3.0-devel2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=678a4a36b07b2b526e6de41149673e4475ad7d9f;p=thirdparty%2Fmdadm.git Abort sysfs_read early if no device found. sysfs_read currently tried to look in sysfs even in no valid sys_name was found. Don't to that. Signed-off-by: NeilBrown --- diff --git a/sysfs.c b/sysfs.c index 7f94d556..b9fd3da9 100644 --- a/sysfs.c +++ b/sysfs.c @@ -81,6 +81,7 @@ int sysfs_open(int devnum, char *devname, char *attr) void sysfs_init(struct mdinfo *mdi, int fd, int devnum) { + mdi->sys_name[0] = 0; if (fd >= 0) { mdu_version_t vers; if (ioctl(fd, RAID_VERSION, &vers) != 0) @@ -118,6 +119,10 @@ struct mdinfo *sysfs_read(int fd, int devnum, unsigned long options) return sra; memset(sra, 0, sizeof(*sra)); sysfs_init(sra, fd, devnum); + if (sra->sys_name[0] == 0) { + free(sra); + return NULL; + } sprintf(fname, "/sys/block/%s/md/", sra->sys_name); base = fname + strlen(fname);