summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2018-08-09 09:34:12 +0200
committerJean Delvare <jdelvare@suse.de>2018-08-09 09:34:12 +0200
commit2818946fc800aaefa7fd25d52e45babd6db13d9b (patch)
tree64fa6cd930a12402fa7a81abddd9d78798f548a2 /util.c
parentbd78a5dfd47043db08982464bcae4759c0980975 (diff)
downloaddmidecode-git-2818946fc800aaefa7fd25d52e45babd6db13d9b.tar.gz
util: Don't close the same file descriptor twice
If myread() fails, it closes the file descriptor it was reading from. On success, it does not. The caller is always closing the file descriptor afterward, which results in double close in the error case. This causes an additional error: /dev/mem: Bad file descriptor As the caller is always taking care of closing the file descriptor, there is no need for myread() to do it. Signed-off-by: Jean Delvare <jdelvare@suse.de> Fixes: 458f73d58c24 ("Fix error paths in mem_chunk")
Diffstat (limited to 'util.c')
-rw-r--r--util.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/util.c b/util.c
index 7049817..1b95e87 100644
--- a/util.c
+++ b/util.c
@@ -59,7 +59,6 @@ static int myread(int fd, u8 *buf, size_t count, const char *prefix)
{
if (errno != EINTR)
{
- close(fd);
perror(prefix);
return -1;
}
@@ -70,7 +69,6 @@ static int myread(int fd, u8 *buf, size_t count, const char *prefix)
if (r2 != count)
{
- close(fd);
fprintf(stderr, "%s: Unexpected end of file\n", prefix);
return -1;
}