Skip to contentSkip to conversation

ipc: mqueue: fix possible memory leak in init_mqueue_fs()

PATCH Applied Hangyu Hua 2 participants 3 messages Jul 15, 2022 – Jul 19, 2022

lore
Share & tools
lore

Hangyu Hua

author
#0 lore raw

PATCH 1/1 ipc: mqueue: fix possible memory leak in init_mqueue_fs()

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")
---
 ipc/mqueue.c | 1 +
 1 file changed, 1 insertion(+)
ipc/mqueue.c +1 -0
index 12ad7860bb88..83370fef8879 100644
@@ -1746,6 +1746,7 @@ static int __init init_mqueue_fs(void)
 	unregister_filesystem(&mqueue_fs_type);
 out_sysctl:
 	kmem_cache_destroy(mqueue_inode_cachep);
+	retire_mq_sysctls(&init_ipc_ns);
 	return error;
 }
 
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · Hangyu Hua

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.

Alex can you review this change?

Quoted 11 lines
Fixes dc55e35f9e81 ("ipc: Store mqueue sysctls in the ipc namespace")
---
 ipc/mqueue.c | 1 +
 1 file changed, 1 insertion(+)
ipc/mqueue.c +0 -0
index 12ad7860bb88..83370fef8879 100644

ipc/mqueue.c static int __init init_mqueue_fs(void) · line 1751

Quoted 6 lines
ipc/mqueue.c +1 -0
@@ -1746,6 +1746,7 @@ static int __init init_mqueue_fs(void)
 	unregister_filesystem(&mqueue_fs_type);
 out_sysctl:
 	kmem_cache_destroy(mqueue_inode_cachep);
+	retire_mq_sysctls(&init_ipc_ns);
 	return error;
 }

Thanks,
Eric

#2 lore raw
In reply to Hangyu Hua
Quoted 6 lines · Hangyu Hua

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.

Applied. Thank you.

Quoted 18 lines
Fixes dc55e35f9e81 ("ipc: Store mqueue sysctls in the ipc namespace")
---
 ipc/mqueue.c | 1 +
 1 file changed, 1 insertion(+)
ipc/mqueue.c +1 -0
index 12ad7860bb88..83370fef8879 100644
@@ -1746,6 +1746,7 @@ static int __init init_mqueue_fs(void)
 	unregister_filesystem(&mqueue_fs_type);
 out_sysctl:
 	kmem_cache_destroy(mqueue_inode_cachep);
+	retire_mq_sysctls(&init_ipc_ns);
 	return error;
 }