* [PATCH] staging: greybus: Remove module from list before freeing in gb_audio_module_release
@ 2024-12-23 15:11 Atharva Tiwari
2024-12-23 18:05 ` Greg Kroah-Hartman
0 siblings, 1 reply; 5+ messages in thread
From: Atharva Tiwari @ 2024-12-23 15:11 UTC (permalink / raw)
Cc: evepolonium, Vaibhav Agarwal, Mark Greer, Johan Hovold,
Alex Elder, Greg Kroah-Hartman, greybus-dev, linux-staging,
linux-kernel
Previously,the module was freed without detaching it from the list which could lead to memory leak
this patch uses list_del to safely remove the module from the list
Signed-off-by: Atharva Tiwari <evepolonium@gmail.com>
---
drivers/staging/greybus/audio_manager_module.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/greybus/audio_manager_module.c b/drivers/staging/greybus/audio_manager_module.c
index 4a4dfb42f50f..7e52c3f95692 100644
--- a/drivers/staging/greybus/audio_manager_module.c
+++ b/drivers/staging/greybus/audio_manager_module.c
@@ -69,7 +69,8 @@ static void gb_audio_module_release(struct kobject *kobj)
struct gb_audio_manager_module *module = to_gb_audio_module(kobj);
pr_info("Destroying audio module #%d\n", module->id);
- /* TODO -> delete from list */
+ if (module->list.prev && module->list.next)
+ list_del(&module->list);
kfree(module);
}
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: greybus: Remove module from list before freeing in gb_audio_module_release
2024-12-23 15:11 [PATCH] staging: greybus: Remove module from list before freeing in gb_audio_module_release Atharva Tiwari
@ 2024-12-23 18:05 ` Greg Kroah-Hartman
2024-12-24 5:19 ` [PATCH] staging: greybus: Remove Module " Atharva Tiwari
0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2024-12-23 18:05 UTC (permalink / raw)
To: Atharva Tiwari
Cc: Vaibhav Agarwal, Mark Greer, Johan Hovold, Alex Elder,
greybus-dev, linux-staging, linux-kernel
On Mon, Dec 23, 2024 at 08:41:12PM +0530, Atharva Tiwari wrote:
> Previously,the module was freed without detaching it from the list which could lead to memory leak
> this patch uses list_del to safely remove the module from the list
>
> Signed-off-by: Atharva Tiwari <evepolonium@gmail.com>
> ---
> drivers/staging/greybus/audio_manager_module.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/greybus/audio_manager_module.c b/drivers/staging/greybus/audio_manager_module.c
> index 4a4dfb42f50f..7e52c3f95692 100644
> --- a/drivers/staging/greybus/audio_manager_module.c
> +++ b/drivers/staging/greybus/audio_manager_module.c
> @@ -69,7 +69,8 @@ static void gb_audio_module_release(struct kobject *kobj)
> struct gb_audio_manager_module *module = to_gb_audio_module(kobj);
>
> pr_info("Destroying audio module #%d\n", module->id);
> - /* TODO -> delete from list */
> + if (module->list.prev && module->list.next)
For lists, you really shouldn't poke around in the prev and next
pointers, right?
Have you tested this? This feels like an odd change, is it a real
system that is using this code anymore?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] staging: greybus: Remove Module from list before freeing in gb_audio_module_release
2024-12-23 18:05 ` Greg Kroah-Hartman
@ 2024-12-24 5:19 ` Atharva Tiwari
2024-12-24 5:43 ` Greg KH
2025-01-06 9:51 ` Dan Carpenter
0 siblings, 2 replies; 5+ messages in thread
From: Atharva Tiwari @ 2024-12-24 5:19 UTC (permalink / raw)
To: gregkh
Cc: elder, evepolonium, greybus-dev, johan, linux-kernel,
linux-staging, mgreer, vaibhav.sr
Yes I have tested the patch with greybus drivers enabled on Debian 12.It works as expected, and i did not get any errors or warning during the compilation
Please let me know if further changes are required.
Best regards,
Atharva Tiwari
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: greybus: Remove Module from list before freeing in gb_audio_module_release
2024-12-24 5:19 ` [PATCH] staging: greybus: Remove Module " Atharva Tiwari
@ 2024-12-24 5:43 ` Greg KH
2025-01-06 9:51 ` Dan Carpenter
1 sibling, 0 replies; 5+ messages in thread
From: Greg KH @ 2024-12-24 5:43 UTC (permalink / raw)
To: Atharva Tiwari
Cc: elder, greybus-dev, johan, linux-kernel, linux-staging, mgreer,
vaibhav.sr
On Tue, Dec 24, 2024 at 10:49:17AM +0530, Atharva Tiwari wrote:
> Yes I have tested the patch with greybus drivers enabled on Debian 12.It works as expected, and i did not get any errors or warning during the compilation
I have no context here, sorry.
Remember, some of use get over 1000 emails a day to do something with,
always respond with proper email quoting and context of what is going
on.
Also, just bulding code does not mean it works :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] staging: greybus: Remove Module from list before freeing in gb_audio_module_release
2024-12-24 5:19 ` [PATCH] staging: greybus: Remove Module " Atharva Tiwari
2024-12-24 5:43 ` Greg KH
@ 2025-01-06 9:51 ` Dan Carpenter
1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2025-01-06 9:51 UTC (permalink / raw)
To: Atharva Tiwari
Cc: gregkh, elder, greybus-dev, johan, linux-kernel, linux-staging,
mgreer, vaibhav.sr
On Tue, Dec 24, 2024 at 10:49:17AM +0530, Atharva Tiwari wrote:
> Yes I have tested the patch with greybus drivers enabled on Debian 12.It works as expected, and i did not get any errors or warning during the compilation
>
> Please let me know if further changes are required.
>
You're trying to ensure that the list is initialized but instead of testing
for that, the correct way is to initialize it earlier in the process.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-01-06 9:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-23 15:11 [PATCH] staging: greybus: Remove module from list before freeing in gb_audio_module_release Atharva Tiwari
2024-12-23 18:05 ` Greg Kroah-Hartman
2024-12-24 5:19 ` [PATCH] staging: greybus: Remove Module " Atharva Tiwari
2024-12-24 5:43 ` Greg KH
2025-01-06 9:51 ` Dan Carpenter
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).