diff options
author | Dan Williams <dan.j.williams@intel.com> | 2008-10-02 03:49:53 +0200 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2008-10-15 23:15:52 +0200 |
commit | 1e4bc070a73716292c1681a86524f46f656f8acb (patch) | |
tree | dcc03fc5eb334191a3f0f179d1adbe5a499cbc1e /sysfs.c | |
parent | non-trivial warn_unused_result fix, prepare_update (diff) | |
download | mdadm-1e4bc070a73716292c1681a86524f46f656f8acb.tar.xz mdadm-1e4bc070a73716292c1681a86524f46f656f8acb.zip |
sysfs_open leaks devnum2devname() result
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'sysfs.c')
-rw-r--r-- | sysfs.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -61,8 +61,12 @@ int sysfs_open(int devnum, char *devname, char *attr) { char fname[50]; int fd; + char *mdname = devnum2devname(devnum); - sprintf(fname, "/sys/block/%s/md/", devnum2devname(devnum)); + if (!mdname) + return -1; + + sprintf(fname, "/sys/block/%s/md/", mdname); if (devname) { strcat(fname, devname); strcat(fname, "/"); @@ -71,6 +75,7 @@ int sysfs_open(int devnum, char *devname, char *attr) fd = open(fname, O_RDWR); if (fd < 0 && errno == EACCES) fd = open(fname, O_RDONLY); + free(mdname); return fd; } |