[PATCH 28/32] fs: fat: propagate f_lseek failure

Ahmad Fatoum a.fatoum at pengutronix.de
Mon Sep 5 02:55:53 PDT 2022


We store an error code to ret, but don't act on it. Fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 fs/fat/fat.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index 84bfe69089e5..7d888817c145 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -196,6 +196,11 @@ static int fat_open(struct device_d *dev, FILE *file, const char *filename)
 
 	if (file->flags & O_APPEND) {
 		ret = f_lseek(f_file, f_file->fsize);
+		if (ret) {
+			f_close(f_file);
+			free(f_file);
+			return -EINVAL;
+		}
 	}
 
 	file->priv = f_file;
-- 
2.30.2




More information about the barebox mailing list