]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib: do not attempt to close(0) in sysfs_deinit()
authorPetr Uzel <petr.uzel@suse.cz>
Tue, 13 Sep 2011 09:08:46 +0000 (11:08 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 13 Sep 2011 09:38:13 +0000 (11:38 +0200)
If the 'open' fails we 'goto err' which runs 'sysfs_deinit()' on a 'cxt'
which hasn't been fully initialised. The 'dir_fd' is still 0, so
sysfs_deinit calls "close(0)".

Addresses: https://bugzilla.novell.com/show_bug.cgi?id=714151
Reported-by: Diego Ercolani <diego.ercolani@gmail.com>
Analysed-by: Neil Brown <nfbrown@suse.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
lib/sysfs.c

index eec1f243b9051aebadd91c56b24948167b6b2599..ebb3bb508fca9d79c47388dc22578e1034784c2d 100644 (file)
@@ -140,6 +140,7 @@ int sysfs_init(struct sysfs_cxt *cxt, dev_t devno, struct sysfs_cxt *parent)
        int fd, rc = 0;
 
        memset(cxt, 0, sizeof(*cxt));
+       cxt->dir_fd = -1;
 
        if (!sysfs_devno_path(devno, path, sizeof(path)))
                goto err;