mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-08 18:43:21 +01:00
powerpc/cacheinfo: 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(). Signed-off-by: Tobin C. Harding <[email protected]> Reviewed-by: Greg Kroah-Hartman <[email protected]> Reviewed-by: Tyrel Datwyler <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
This commit is contained in:
1 parent
33dda8c327
commit
7e8039795a
1 file changed
+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,
|
||||
|
||||
Reference in new issue
Block a user