From: Karel Zak Date: Wed, 1 Feb 2012 12:03:58 +0000 (+0100) Subject: lib/sysfs: fix possible fd leak on error X-Git-Tag: v2.21-rc2~35 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=06ae069bc362c25847fb8ccfef6a459165e9f901;p=thirdparty%2Futil-linux.git lib/sysfs: fix possible fd leak on error Signed-off-by: Karel Zak --- diff --git a/lib/sysfs.c b/lib/sysfs.c index ebb3bb508f..6e7a1e0aee 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -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: