[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dmidecode] [PATCH 1/3] util: Don't close the same file descriptor twice
From: |
Jean Delvare |
Subject: |
[dmidecode] [PATCH 1/3] util: Don't close the same file descriptor twice |
Date: |
Wed, 1 Aug 2018 11:16:51 +0200 |
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 <address@hidden>
Fixes: 458f73d58c24 ("Fix error paths in mem_chunk")
---
util.c | 2 --
1 file changed, 2 deletions(-)
--- dmidecode.orig/util.c 2018-08-01 10:27:05.874390642 +0200
+++ dmidecode/util.c 2018-08-01 10:27:15.950517651 +0200
@@ -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;
}
--
Jean Delvare
SUSE L3 Support
- [dmidecode] [PATCH 1/3] util: Don't close the same file descriptor twice,
Jean Delvare <=