Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH] lib: do not attempt to close(0) in sysfs_deinit()
@ 2011-09-13  9:08 Petr Uzel
  2011-09-13  9:38 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Petr Uzel @ 2011-09-13  9:08 UTC (permalink / raw)
  To: util-linux; +Cc: Neil F Brown

[-- Attachment #1: Type: text/plain, Size: 883 bytes --]

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 |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/lib/sysfs.c b/lib/sysfs.c
index eec1f24..ebb3bb5 100644
--- a/lib/sysfs.c
+++ b/lib/sysfs.c
@@ -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;
-- 
1.7.3.4


Petr

--
Petr Uzel
IRC: ptr_uzl @ freenode

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-13  9:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-13  9:08 [PATCH] lib: do not attempt to close(0) in sysfs_deinit() Petr Uzel
2011-09-13  9:38 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox