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@xxxxxxxxx> Analysed-by: Neil Brown <nfbrown@xxxxxxxx> Signed-off-by: Petr Uzel <petr.uzel@xxxxxxx> --- 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:
pgpmzT7MY38Cw.pgp
Description: PGP signature