diff options
author | Jean Delvare <jdelvare@suse.de> | 2018-08-09 09:34:12 +0200 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2018-08-09 09:34:12 +0200 |
commit | 2818946fc800aaefa7fd25d52e45babd6db13d9b (patch) | |
tree | 64fa6cd930a12402fa7a81abddd9d78798f548a2 /util.c | |
parent | bd78a5dfd47043db08982464bcae4759c0980975 (diff) | |
download | dmidecode-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.c | 2 |
1 files changed, 0 insertions, 2 deletions
@@ -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; } |