Jean Delvare
2018-08-01 09:16:51 UTC
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 <***@suse.de>
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;
}
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 <***@suse.de>
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
_______________________________________________
https://lists.nongnu.org/mailman/listinfo/dmidecode-devel
Jean Delvare
SUSE L3 Support
_______________________________________________
https://lists.nongnu.org/mailman/listinfo/dmidecode-devel