powerpc: Fix kobject memleak
PATCH 1/1 powerpc: Fix kobject memleak
Currently error return from kobject_init_and_add() is not followed by a call to kobject_put(). This means there is a memory leak.
Add call to kobject_put() in error path of kobject_init_and_add().
---
Untested, did not even build. Bad Tobin, no biscuit.
No call to kobject_uevent()? I'll be back to check usage of kobject_create_and_add() later, then I intend to check all the uevent stuff, feel free to leave this for me to check later if you don't know the reasoning straight off the top of your head.
thanks,
Tobin.
arch/powerpc/kernel/cacheinfo.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
arch/powerpc/kernel/cacheinfo.c +6 -7
@@ -759,23 +759,22 @@ static void cacheinfo_create_index_dir(struct cache *cache, int index, index_dir =kzalloc (sizeof (*index_dir),GFP_KERNEL );if (!index_dir) - goto err; +return ; index_dir->cache = cache; rc =kobject_init_and_add (&index_dir->kobj, &cache_index_type, cache_dir->kobj,"index%d" , index); -if (rc) - goto err; +if (rc) { +kobject_put (&index_dir->kobj); +kfree (index_dir); +return ; + } index_dir->next = cache_dir->index; cache_dir->index = index_dir;cacheinfo_create_index_opt_attrs (index_dir); - -return ; -err: -kfree (index_dir); } static void cacheinfo_sysfs_populate(unsigned int cpu_id,
Signature · 1 line
2.21.0
Quoted 6 lines · Tobin C. Harding
Currently error return from
kobject_init_and_add()is not followed by a call tokobject_put(). This means there is a memory leak.Add call to
kobject_put()in error path ofkobject_init_and_add().Signed-off-by Tobin C. Harding <[email protected]>
Quoted 7 lines · Tobin C. Harding
Currently error return from
kobject_init_and_add()is not followed by a call tokobject_put(). This means there is a memory leak.Add call to
kobject_put()in error path ofkobject_init_and_add().Signed-off-by Tobin C. Harding <[email protected]>---
Michael Ellerman
AppliedQuoted 8 lines · Tobin C. Harding
Currently error return from
kobject_init_and_add()is not followed by a call tokobject_put(). This means there is a memory leak.Add call to
kobject_put()in error path ofkobject_init_and_add().Signed-off-by Tobin C. Harding <[email protected]>Reviewed-by Greg Kroah-Hartman <[email protected]>Reviewed-by Tyrel Datwyler <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/7e8039795a80bdf1418964b9cabef616
cheers