File util-dont-close-the-same-file-descriptor-twice.patch of Package dmidecode.28672
From: Jean Delvare <jdelvare@suse.de>
Date: Thu, 9 Aug 2018 09:34:12 +0200
Subject: util: Don't close the same file descriptor twice
Git-commit: 2818946fc800aaefa7fd25d52e45babd6db13d9b
Patch-mainline: 3.2
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")
---
util.c | 2 --
1 file changed, 2 deletions(-)
--- a/util.c
+++ b/util.c
@@ -59,7 +59,6 @@ static int myread(int fd, u8 *buf, size_
{
if (errno != EINTR)
{
- close(fd);
perror(prefix);
return -1;
}
@@ -70,7 +69,6 @@ static int myread(int fd, u8 *buf, size_
if (r2 != count)
{
- close(fd);
fprintf(stderr, "%s: Unexpected end of file\n", prefix);
return -1;
}