[PATCH mtd-utils 4/7] jffsX-utils: jffs2reader: Fix potential null pointer dereference compiling warning for 'path'

Zhihao Cheng chengzhihao1 at huawei.com
Sat Jan 25 22:42:00 PST 2025


The compiler compains following message:
 jffsX-utils/jffs2reader.c:697:6: warning: potential null pointer
 dereference
It won't bring any problems because the 'path' is guaranteed to be a
non-NULL variable. Fix the warning by adding a NULL pointer check.

Signed-off-by: Zhihao Cheng <chengzhihao1 at huawei.com>
---
 jffsX-utils/jffs2reader.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/jffsX-utils/jffs2reader.c b/jffsX-utils/jffs2reader.c
index 87a2167..548fc8d 100644
--- a/jffsX-utils/jffs2reader.c
+++ b/jffsX-utils/jffs2reader.c
@@ -694,6 +694,9 @@ static struct jffs2_raw_dirent *resolvepath0(char *o, size_t size, uint32_t ino,
 
 	pp = path = xstrdup(p);
 
+	if (path == NULL)
+		return NULL;
+
 	if (*path == '/') {
 		path++;
 		ino = 1;
-- 
2.13.6




More information about the linux-mtd mailing list