linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 5.10] gasket: make interrupt_data NULL after free
@ 2023-07-07 13:47 Anastasia Belova
  2023-07-16 15:20 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Anastasia Belova @ 2023-07-07 13:47 UTC (permalink / raw)
  To: Rob Springer
  Cc: Anastasia Belova, Todd Poynor, Ben Chan, Richard Yeh,
	Greg Kroah-Hartman, John Joseph, Simon Que, linux-staging,
	linux-kernel, lvc-project

Gasket common interrupt module was deleted in version 5.13, 
but there is possible double free in versions 4.19-5.12.

gasket_dev->interrupt_data should be NULL when
gasket_interrupt_init returns error. For example,
it is necessary in gasket_enable_device to avoid
double free.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
---
 drivers/staging/gasket/gasket_interrupt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c
index 864342acfd86..24fa5df0628b 100644
--- a/drivers/staging/gasket/gasket_interrupt.c
+++ b/drivers/staging/gasket/gasket_interrupt.c
@@ -337,6 +337,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev)
 			sizeof(*interrupt_data->eventfd_ctxs), GFP_KERNEL);
 	if (!interrupt_data->eventfd_ctxs) {
 		kfree(interrupt_data);
+		gasket_dev->interrupt_data = NULL;
 		return -ENOMEM;
 	}
 
@@ -346,6 +347,7 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev)
 	if (!interrupt_data->interrupt_counts) {
 		kfree(interrupt_data->eventfd_ctxs);
 		kfree(interrupt_data);
+		gasket_dev->interrupt_data = NULL;
 		return -ENOMEM;
 	}
 
-- 
2.30.2


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

end of thread, other threads:[~2023-07-16 15:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-07 13:47 [PATCH 5.10] gasket: make interrupt_data NULL after free Anastasia Belova
2023-07-16 15:20 ` 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;
as well as URLs for NNTP newsgroup(s).