[PATCH] read_file_2: Fix return value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Signed-off-by: Teresa Gámez <t.gamez@xxxxxxxxx>
---
 lib/libfile.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/lib/libfile.c b/lib/libfile.c
index c6fb6d7..c626e2f 100644
--- a/lib/libfile.c
+++ b/lib/libfile.c
@@ -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)
-- 
1.7.0.4


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux