diff options
author | NeilBrown <neilb@suse.de> | 2008-11-04 10:56:11 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2008-11-04 10:56:11 +0100 |
commit | 678a4a36b07b2b526e6de41149673e4475ad7d9f (patch) | |
tree | 32d6d5006d25dbfbf18f4bb588553759ba121951 /sysfs.c | |
parent | mdopen: only let numeric name set minor number if it doesn't cause a conflict. (diff) | |
download | mdadm-678a4a36b07b2b526e6de41149673e4475ad7d9f.tar.xz mdadm-678a4a36b07b2b526e6de41149673e4475ad7d9f.zip |
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 <neilb@suse.de>
Diffstat (limited to 'sysfs.c')
-rw-r--r-- | sysfs.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -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); |