]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/sysfs: fix possible fd leak on error
authorKarel Zak <kzak@redhat.com>
Wed, 1 Feb 2012 12:03:58 +0000 (13:03 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 1 Feb 2012 12:03:58 +0000 (13:03 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/sysfs.c

index ebb3bb508fca9d79c47388dc22578e1034784c2d..6e7a1e0aeedb155466a4e19faf63e51bc201268e 100644 (file)
@@ -148,11 +148,12 @@ int sysfs_init(struct sysfs_cxt *cxt, dev_t devno, struct sysfs_cxt *parent)
        fd = open(path, O_RDONLY);
        if (fd < 0)
                goto err;
+       cxt->dir_fd = fd;
+
        cxt->dir_path = strdup(path);
        if (!cxt->dir_path)
                goto err;
        cxt->devno = devno;
-       cxt->dir_fd = fd;
        cxt->parent = parent;
        return 0;
 err: