From: Petr Uzel Date: Tue, 13 Sep 2011 09:08:46 +0000 (+0200) Subject: lib: do not attempt to close(0) in sysfs_deinit() X-Git-Tag: v2.20.1~30 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=718d3b9814a46435696421f94df0aa75fc500875;p=thirdparty%2Futil-linux.git 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 Reported-by: Diego Ercolani Analysed-by: Neil Brown Signed-off-by: Petr Uzel --- diff --git a/lib/sysfs.c b/lib/sysfs.c index eec1f243b9..ebb3bb508f 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;