linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
* [f2fs-dev] [PATCH] f2fs-tools: fix to call assert() if f2fs_dentry_hash() fails
@ 2023-06-08 10:12 Chao Yu
  0 siblings, 0 replies; only message in thread
From: Chao Yu @ 2023-06-08 10:12 UTC (permalink / raw)
  To: jaegeuk; +Cc: linux-f2fs-devel

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 --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);
-- 
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-08 10:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-08 10:12 [f2fs-dev] [PATCH] f2fs-tools: fix to call assert() if f2fs_dentry_hash() fails Chao Yu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).