diff mbox series

[f2fs-dev] f2fs-tools: fix to call assert() if f2fs_dentry_hash() fails

Message ID 20230608101230.3671677-1-chao@kernel.org (mailing list archive)
State New
Headers show
Series [f2fs-dev] f2fs-tools: fix to call assert() if f2fs_dentry_hash() fails | expand

Commit Message

Chao Yu June 8, 2023, 10:12 a.m. UTC
f2fs_dentry_hash() may return -ENOMEM due to malloc() failure, however
caller won't check validaty of return value, result assign or check
wrong hash value, fix to call assert() for such case.

Signed-off-by: Chao Yu <chao@kernel.org>
---
 lib/libf2fs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 7a08a7f..0ab7342 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -497,8 +497,8 @@  f2fs_hash_t f2fs_dentry_hash(int encoding, int casefolded,
 
 	if (len && casefolded) {
 		buff = malloc(sizeof(char) * PATH_MAX);
-		if (!buff)
-			return -ENOMEM;
+		ASSERT(buff);
+
 		dlen = table->ops->casefold(table, name, len, buff, PATH_MAX);
 		if (dlen < 0) {
 			free(buff);