staging: greybus: Remove module from list before freeing in gb_audio_module_release
Subsystems (3)
PATCH 1/1 staging: greybus: Remove module from list before freeing in gb_audio_module_release
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
--- drivers/staging/greybus/audio_manager_module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/greybus/audio_manager_module.c +2 -1
@@ -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); }
Signature · 1 line
2.39.5
Greg Kroah-Hartman
maintainerQuoted 13 lines · Atharva Tiwari
Previously,the module was freed without detaching it from the list which could lead to memory leak this patch uses
list_delto safely remove the module from the listSigned-off-by Atharva Tiwari <[email protected]>--- drivers/staging/greybus/audio_manager_module.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/staging/greybus/audio_manager_module.c +0
-0
drivers/staging/greybus/audio_manager_module.c static void gb_audio_module_release(struct kobject *kobj) · line 72
Quoted 5 lines
drivers/staging/greybus/audio_manager_module.c +1
-1@@ -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
PATCH 1/1 staging: greybus: Remove Module from list before freeing in gb_audio_module_release
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
Greg KH
maintainerRe: [PATCH] staging: greybus: Remove Module from list before freeing in gb_audio_module_release
Quoted 1 line · Atharva Tiwari
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
Re: [PATCH] staging: greybus: Remove Module from list before freeing in gb_audio_module_release
In reply to Atharva TiwariQuoted 4 lines · Atharva Tiwari
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