[PATCH] configfs: fix NULL dereference in configfs_depend_item_unlocked()

From: pavankumaryalagada

Date: Mon Sep 14 2026 - 05:57:33 EST


From: Yalagada Pavan Kumar <pavankumaryalagada@xxxxxxxxx>

configfs_depend_item_unlocked() can dereference a NULL parent when
the configfs item is still being created.

The item can be found before it is linked to its parent group,
so ci_group can still be NULL. Check ci_group before using it
and return -ENOENT if it is NULL.

Reported-by: syzbot+a9efa71b884a23e74153@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=a9efa71b884a23e74153
Fixes: 4bb8548df632 ("usb: gadget: f_tcm: add configfs support")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Yalagada Pavan Kumar <pavankumaryalagada@xxxxxxxxx>
---
fs/configfs/dir.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index eda80c2a2d38..301a64f41887 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -1244,6 +1244,9 @@ int configfs_depend_item_unlocked(struct configfs_subsystem *caller_subsys,
return -EINVAL;

parent = target->ci_group;
+ if (!parent)
+ return -ENOENT;
+
/*
* This may happen when someone is trying to depend root
* directory of some subsystem
--
2.43.0