]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ipc: mqueue: fix possible memory leak in init_mqueue_fs()
authorHangyu Hua <hbh25y@gmail.com>
Fri, 15 Jul 2022 06:23:01 +0000 (14:23 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Oct 2022 10:38:55 +0000 (12:38 +0200)
[ Upstream commit c579d60f0d0cd87552f64fdebe68b5d941d20309 ]

commit db7cfc380900 ("ipc: Free mq_sysctls if ipc namespace creation
failed")

Here's a similar memory leak to the one fixed by the patch above.
retire_mq_sysctls need to be called when init_mqueue_fs fails after
setup_mq_sysctls.

Fixes: dc55e35f9e81 ("ipc: Store mqueue sysctls in the ipc namespace")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
Link: https://lkml.kernel.org/r/20220715062301.19311-1-hbh25y@gmail.com
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
ipc/mqueue.c

index f98de32aeea174c440e084362bcca1c3edfe5e3c..9cf314b3f079f4cff2b12e588bdc0d1faac6d57c 100644 (file)
@@ -1746,6 +1746,7 @@ out_filesystem:
        unregister_filesystem(&mqueue_fs_type);
 out_sysctl:
        kmem_cache_destroy(mqueue_inode_cachep);
+       retire_mq_sysctls(&init_ipc_ns);
        return error;
 }