summaryrefslogtreecommitdiffstats
path: root/libblkid/src/save.c
diff options
context:
space:
mode:
authorKarel Zak2012-09-07 11:00:54 +0200
committerKarel Zak2012-09-07 11:01:07 +0200
commitceaff03b27d3e5be9263c980ce8006854c4bff60 (patch)
tree1ce01729ed6059c79a681eeacc928a8123c0dd00 /libblkid/src/save.c
parentlibblkid: improve DBG() macro (diff)
downloadkernel-qcow2-util-linux-ceaff03b27d3e5be9263c980ce8006854c4bff60.tar.gz
kernel-qcow2-util-linux-ceaff03b27d3e5be9263c980ce8006854c4bff60.tar.xz
kernel-qcow2-util-linux-ceaff03b27d3e5be9263c980ce8006854c4bff60.zip
libblkid: check fchmod() return value [coverity scan]
Diffstat (limited to 'libblkid/src/save.c')
-rw-r--r--libblkid/src/save.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libblkid/src/save.c b/libblkid/src/save.c
index f0008ae53..7ce6fa498 100644
--- a/libblkid/src/save.c
+++ b/libblkid/src/save.c
@@ -110,10 +110,13 @@ int blkid_flush_cache(blkid_cache cache)
sprintf(tmp, "%s-XXXXXX", filename);
fd = mkstemp(tmp);
if (fd >= 0) {
- file = fdopen(fd, "w");
- opened = tmp;
+ if (fchmod(fd, 0644) != 0)
+ DBG(DEBUG_SAVE, printf("%s: fchmod failed\n", filename));
+ else if ((file = fdopen(fd, "w")))
+ opened = tmp;
+ if (!file)
+ close(fd);
}
- fchmod(fd, 0644);
}
}