]> Git Repo - linux.git/commitdiff
ipc: fix memory leak in init_mqueue_fs()
authorZhengchao Shao <[email protected]>
Fri, 9 Dec 2022 09:29:29 +0000 (17:29 +0800)
committerAndrew Morton <[email protected]>
Mon, 12 Dec 2022 03:30:20 +0000 (19:30 -0800)
When setup_mq_sysctls() failed in init_mqueue_fs(), mqueue_inode_cachep is
not released.  In order to fix this issue, the release path is reordered.

Link: https://lkml.kernel.org/r/[email protected]
Fixes: dc55e35f9e81 ("ipc: Store mqueue sysctls in the ipc namespace")
Signed-off-by: Zhengchao Shao <[email protected]>
Cc: Alexey Gladkov <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Jingyu Wang <[email protected]>
Cc: Muchun Song <[email protected]>
Cc: Roman Gushchin <[email protected]>
Cc: Waiman Long <[email protected]>
Cc: Wei Yongjun <[email protected]>
Cc: YueHaibing <[email protected]>
Cc: Yu Zhe <[email protected]>
Cc: Manfred Spraul <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
ipc/mqueue.c

index 467a194b8a2ec6464f475fca5c5ff569002ed018..d09aa1c1e3e653b70e3788d0359517bcb92982b9 100644 (file)
@@ -1726,7 +1726,8 @@ static int __init init_mqueue_fs(void)
 
        if (!setup_mq_sysctls(&init_ipc_ns)) {
                pr_warn("sysctl registration failed\n");
-               return -ENOMEM;
+               error = -ENOMEM;
+               goto out_kmem;
        }
 
        error = register_filesystem(&mqueue_fs_type);
@@ -1744,8 +1745,9 @@ static int __init init_mqueue_fs(void)
 out_filesystem:
        unregister_filesystem(&mqueue_fs_type);
 out_sysctl:
-       kmem_cache_destroy(mqueue_inode_cachep);
        retire_mq_sysctls(&init_ipc_ns);
+out_kmem:
+       kmem_cache_destroy(mqueue_inode_cachep);
        return error;
 }
 
This page took 0.050731 seconds and 4 git commands to generate.