mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: fix use-after-free in dump_module
@ 2026-10-30 15:03 linfordWu
  2026-10-30 15:17 ` Dan Carpenter
  2026-10-30 15:21 ` Greg Kroah-Hartman
  0 siblings, 2 replies; 3+ messages in thread
From: linfordWu @ 2026-10-30 15:03 UTC (permalink / raw)
  To: Vaibhav Agarwal, Mark Greer, Johan Hovold, Alex Elder,
	Greg Kroah-Hartman
  Cc: greybus-dev, linux-staging, linux-kernel, linfordWu

gb_audio_manager_dump_module() drops modules_rwsem before dereferencing
the module. A concurrent gb_audio_manager_remove() can free the module
between the lookup and the dump.

Keep the read lock held while dumping the module so removal cannot free
it during the access.

Signed-off-by: linfordWu <linfordwu@163.com>
---
 drivers/staging/greybus/audio_manager.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/greybus/audio_manager.c b/drivers/staging/greybus/audio_manager.c
index 118ada9b909..1b91acc084f 100644
--- a/drivers/staging/greybus/audio_manager.c
+++ b/drivers/staging/greybus/audio_manager.c
@@ -117,12 +117,13 @@ int gb_audio_manager_dump_module(int id)
 
 	down_read(&modules_rwsem);
 	module = gb_audio_manager_get_locked(id);
-	up_read(&modules_rwsem);
-
-	if (!module)
+	if (!module) {
+		up_read(&modules_rwsem);
 		return -EINVAL;
+	}
 
 	gb_audio_manager_module_dump(module);
+	up_read(&modules_rwsem);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(gb_audio_manager_dump_module);
-- 
2.43.0


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

end of thread, other threads:[~2026-10-30 15:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-30 15:03 [PATCH] staging: greybus: fix use-after-free in dump_module linfordWu
2026-10-30 15:17 ` Dan Carpenter
2026-10-30 15:21 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®