]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/sysfs: make sysfs_next_subsystem() more robust
authorKarel Zak <kzak@redhat.com>
Mon, 31 Aug 2015 08:11:01 +0000 (10:11 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 31 Aug 2015 08:11:01 +0000 (10:11 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/sysfs.c

index caf89bf536e9cfec251d145c0ba826ef687d151f..d2146d5fb986ad79f4d3e3abefe9f961c01ec10d 100644 (file)
@@ -658,6 +658,8 @@ int sysfs_next_subsystem(struct sysfs_cxt *cxt __attribute__((unused)),
        if (!subsys || !devchain)
                return -EINVAL;
 
+       *subsys = NULL;
+
        while ((sub = get_subsystem(devchain, subbuf, sizeof(subbuf)))) {
                *subsys = strdup(sub);
                if (!*subsys)