[PATCH 1/1] fs/fat: correct handling of full directory

Heinrich Schuchardt xypron.glpk at gmx.de
Tue Jul 12 21:56:55 CEST 2022


If fat_create_dir_entry() fails, e.g. if the root directory is full,
file_fat_write_at() must not try to write the file.

Fixes: 10abea4f851a ("fs: fat: carve out fat_create_dir_entry()")
Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 fs/fat/fat_write.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c
index a25b2283d4..ee28ca5f14 100644
--- a/fs/fat/fat_write.c
+++ b/fs/fat/fat_write.c
@@ -1428,6 +1428,11 @@ int file_fat_write_at(const char *filename, loff_t pos, void *buffer,
 		}

 		ret = fat_create_dir_entry(itr, basename, size, ATTR_ARCH);
+		if (ret < 0) {
+			log_err("Can't create directory entry\n");
+			ret = -EIO;
+			goto exit;
+		}

 		retdent = itr->dent;
 	}
--
2.30.2



More information about the U-Boot mailing list