From: Petr Uzel <petr.uzel@suse.cz>
To: util-linux <util-linux@vger.kernel.org>
Cc: Neil F Brown <nfbrown@suse.com>
Subject: [PATCH] lib: do not attempt to close(0) in sysfs_deinit()
Date: Tue, 13 Sep 2011 11:08:46 +0200 [thread overview]
Message-ID: <20110913090845.GA8203@foxbat.suse.cz> (raw)
[-- 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 --]
next reply other threads:[~2011-09-13 9:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-13 9:08 Petr Uzel [this message]
2011-09-13 9:38 ` [PATCH] lib: do not attempt to close(0) in sysfs_deinit() Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110913090845.GA8203@foxbat.suse.cz \
--to=petr.uzel@suse.cz \
--cc=nfbrown@suse.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox