diff options
author | Karel Zak | 2017-05-17 12:43:48 +0200 |
---|---|---|
committer | Karel Zak | 2017-05-17 12:43:48 +0200 |
commit | 199f8cd3b5c3434e2a1cd6e563f2c2e4a37c203b (patch) | |
tree | 1df48434e7320c5dcfaf838f5f1faaee9ae4f10f /libfdisk/src/context.c | |
parent | libmount: fix memory leak [coverity scan] (diff) | |
download | kernel-qcow2-util-linux-199f8cd3b5c3434e2a1cd6e563f2c2e4a37c203b.tar.gz kernel-qcow2-util-linux-199f8cd3b5c3434e2a1cd6e563f2c2e4a37c203b.tar.xz kernel-qcow2-util-linux-199f8cd3b5c3434e2a1cd6e563f2c2e4a37c203b.zip |
libfdisk: don't use errno after close()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/context.c')
-rw-r--r-- | libfdisk/src/context.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index 02b035c92..4fe24d011 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -537,7 +537,7 @@ static void reset_context(struct fdisk_context *cxt) int fdisk_assign_device(struct fdisk_context *cxt, const char *fname, int readonly) { - int fd; + int fd, rc = 0; DBG(CXT, ul_debugobj(cxt, "assigning device %s", fname)); assert(cxt); @@ -598,10 +598,11 @@ int fdisk_assign_device(struct fdisk_context *cxt, fname, readonly ? "READ-ONLY" : "READ-WRITE")); return 0; fail: + rc = -errno; if (fd >= 0) close(fd); DBG(CXT, ul_debugobj(cxt, "failed to assign device")); - return -errno; + return rc; } /** |