All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fs: squasfs: fix a possible NULL pointer dereference in sqfs_opendir()
@ 2020-12-18 14:24 Richard Genoud
  2020-12-18 18:50 ` Miquel Raynal
  0 siblings, 1 reply; 12+ messages in thread
From: Richard Genoud @ 2020-12-18 14:24 UTC (permalink / raw)
  To: u-boot

token_count may be != 0 and token_list not yet allocated when the out
code is reached

Reported-by: Coverity CID 313547
Fixes: ea1b1651c6a8 ("fs/squashfs: sqfs_opendir: simplify error handling")
Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
---
 fs/squashfs/sqfs.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c
index 608a2bb454c..c47046b76e5 100644
--- a/fs/squashfs/sqfs.c
+++ b/fs/squashfs/sqfs.c
@@ -949,8 +949,9 @@ int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp)
 	*dirsp = (struct fs_dir_stream *)dirs;
 
 out:
-	for (j = 0; j < token_count; j++)
-		free(token_list[j]);
+	if (token_list)
+		for (j = 0; j < token_count; j++)
+			free(token_list[j]);
 	free(token_list);
 	free(pos_list);
 	free(path);

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-12-22  9:07 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-18 14:24 [PATCH] fs: squasfs: fix a possible NULL pointer dereference in sqfs_opendir() Richard Genoud
2020-12-18 18:50 ` Miquel Raynal
2020-12-21 15:06   ` Richard Genoud
2020-12-21 15:14     ` Miquel Raynal
2020-12-21 15:26       ` Richard Genoud
2020-12-21 15:29         ` Miquel Raynal
2020-12-21 15:40           ` Richard Genoud
2020-12-21 15:49             ` Miquel Raynal
2020-12-21 16:17               ` Richard Genoud
2020-12-22  7:46                 ` Miquel Raynal
2020-12-22  9:07                   ` Richard Genoud
2020-12-21 15:26       ` Miquel Raynal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.