Skip to contentSkip to conversation

proc: Fix pointer error dereference

PATCH Applied Ethan Tidmore 1 participant 1 message Feb 19

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc: Fix pointer error dereference

The function try_lookup_noperm() can return an error pointer. Add check for error pointer.

Detected by Smatch:
fs/proc/base.c:2148 proc_fill_cache() error:
'child' dereferencing possible ERR_PTR()

Fixes 61a28784028e6 ("proc: Remove the hard coded inode numbers")
---
 fs/proc/base.c | 3 +++
 1 file changed, 3 insertions(+)
fs/proc/base.c +3 -0
index 4eec684baca9..4c863d17dfb4 100644
@@ -2128,6 +2128,9 @@ bool proc_fill_cache(struct file *file, struct dir_context *ctx,
 	ino_t ino = 1;
 
 	child = try_lookup_noperm(&qname, dir);
+	if (IS_ERR(child))
+		goto end_instantiate;
+
 	if (!child) {
 		DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
 		child = d_alloc_parallel(dir, &qname, &wq);
Signature · 1 line
2.53.0