]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Don't ignore errors in sysfs_add_disk.
authorNeil Brown <neilb@suse.de>
Thu, 12 Jun 2008 00:13:19 +0000 (10:13 +1000)
committerNeil Brown <neilb@suse.de>
Thu, 12 Jun 2008 00:13:19 +0000 (10:13 +1000)
i.e. if the add fails, don't add the device to the internal data
structures.

sysfs.c

diff --git a/sysfs.c b/sysfs.c
index dbfb55a85aee3d1e5846b4391405f4f473f90419..344b136103e572e6801e10fe20d80b53591988e5 100644 (file)
--- a/sysfs.c
+++ b/sysfs.c
@@ -390,10 +390,11 @@ int sysfs_add_disk(struct mdinfo *sra, struct mdinfo *sd)
                rv |= sysfs_set_num(sra, sd, "slot", sd->disk.raid_disk);
 //             rv |= sysfs_set_str(sra, sd, "state", "in_sync");
        }
-       sd2 = malloc(sizeof(*sd2));
-       *sd2 = *sd;
-       sd2->next = sra->devs;
-       sra->devs = sd2;
-
+       if (! rv) {
+               sd2 = malloc(sizeof(*sd2));
+               *sd2 = *sd;
+               sd2->next = sra->devs;
+               sra->devs = sd2;
+       }
        return rv;
 }