Skip to contentSkip to conversation

lib: do not attempt to close(0) in sysfs_deinit()

PATCH Applied Petr Uzel 2 participants 2 messages Sep 13, 2011

Subsystems (2)
lore
Share & tools
lore

Petr Uzel

author
#0 lore raw

PATCH 1/1 lib: do not attempt to close(0) in sysfs_deinit()

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

---
 lib/sysfs.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
lib/sysfs.c +1 -0
index eec1f24..ebb3bb5 100644
@@ -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;
Signature · 8 lines
1.7.3.4


Petr

--
Petr Uzel
IRC: ptr_uzl @ freenode
maintainer Applied
#1 lore raw
Quoted 2 lines · Petr Uzel
 lib/sysfs.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Applied, thanks.

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com