diff options
author | Karel Zak | 2017-05-17 12:20:18 +0200 |
---|---|---|
committer | Karel Zak | 2017-05-17 12:28:07 +0200 |
commit | 0a48e2370dd4394050d2be471665ef95dbc22ea1 (patch) | |
tree | 9b07b0981e81e1996bc286abd4ce14f17533c423 /libfdisk/src/context.c | |
parent | libfdisk: don't print uninitialized variable [coverity scan] (diff) | |
download | kernel-qcow2-util-linux-0a48e2370dd4394050d2be471665ef95dbc22ea1.tar.gz kernel-qcow2-util-linux-0a48e2370dd4394050d2be471665ef95dbc22ea1.tar.xz kernel-qcow2-util-linux-0a48e2370dd4394050d2be471665ef95dbc22ea1.zip |
libmount: check fstat() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libfdisk/src/context.c')
-rw-r--r-- | libfdisk/src/context.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/libfdisk/src/context.c b/libfdisk/src/context.c index 7dc16aa78..02b035c92 100644 --- a/libfdisk/src/context.c +++ b/libfdisk/src/context.c @@ -565,9 +565,10 @@ int fdisk_assign_device(struct fdisk_context *cxt, fd = open(fname, (readonly ? O_RDONLY : O_RDWR ) | O_CLOEXEC); if (fd < 0) - return -errno; + goto fail; - fstat(fd, &cxt->dev_st); + if (fstat(fd, &cxt->dev_st) != 0) + goto fail; cxt->readonly = readonly; cxt->dev_fd = fd; @@ -597,6 +598,8 @@ int fdisk_assign_device(struct fdisk_context *cxt, fname, readonly ? "READ-ONLY" : "READ-WRITE")); return 0; fail: + if (fd >= 0) + close(fd); DBG(CXT, ul_debugobj(cxt, "failed to assign device")); return -errno; } |