Skip to contentSkip to conversation

read_file_2: Fix return value

PATCH Applied Teresa Gámez 2 participants 2 messages Sep 24, 2014 – Sep 25, 2014 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 read_file_2: Fix return value

Set return value correct in error case.
This prevents barebox from crashing in some conditions.

---
 lib/libfile.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
lib/libfile.c +3 -1
index c6fb6d7..c626e2f 100644
@@ -163,8 +163,10 @@ again:
 	buf = xzalloc(read_size + 1);
 
 	fd = open(filename, O_RDONLY);
-	if (fd < 0)
+	if (fd < 0) {
+		ret = fd;
 		goto err_out;
+	}
 
 	ret = read_full(fd, buf, read_size);
 	if (ret < 0)
Signature · 7 lines
1.7.0.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 4 lines · Teresa Gámez

Set return value correct in error case.
This prevents barebox from crashing in some conditions.

Applied, thanks

Sascha

Quoted 28 lines
---
 lib/libfile.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
lib/libfile.c +3 -1
index c6fb6d7..c626e2f 100644
@@ -163,8 +163,10 @@ again:
 	buf = xzalloc(read_size + 1);
 
 	fd = open(filename, O_RDONLY);
-	if (fd < 0)
+	if (fd < 0) {
+		ret = fd;
 		goto err_out;
+	}
 
 	ret = read_full(fd, buf, read_size);
 	if (ret < 0)
Signature · 7 lines
1.7.0.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox