sh: fix proc file removal for superh store queue
Subsystems (2)
PATCH 1/1 sh: fix proc file removal for superh store queue
Patch to balance proc file creation and removal for superh store queue module. Currently a failure in module load, or a module unload leaves a proc file registered, causing an oops in the event the proc file is read. This patch corrects that.
Thanks & Regards
Neil
sq.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
arch/sh/kernel/cpu/sh4/sq.c +10 -1
@@ -421,18 +421,27 @@ static struct miscdevice sq_dev = {static int __init sq_api_init (void ) { +int ret;printk (KERN_NOTICE "sq: Registering store queue API.\n" );#ifdef CONFIG_PROC_FS create_proc_read_entry ("sq_mapping" ,0 ,0 , sq_mapping_read_proc,0 );#endif -return misc_register (&sq_dev); + ret =misc_register (&sq_dev); +#ifdef CONFIG_PROC_FS +if (ret) +remove_proc_entry ("sq_mapping" ,NULL ); +#endif +return ret; } static void __exit sq_api_exit(void) {misc_deregister (&sq_dev); +#ifdef CONFIG_PROC_FS +remove_proc_entry ("sq_mapping" ,NULL ); +#endif }module_init (sq_api_init);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [KJ PATCH] sh: fix proc file removal for superh store
Quoted 2 lines
An oops fix isn't a kernel-janitors thing. It's a slam-it-into-mainline-and-consider-a-backport thing.
Quoted 1 line · On Thu, 3 Aug 2006 15:18:28 -0400 Neil Horman <[email protected]> wrote:
Patch to balance proc file creation and removal for superh store queue module.
You have a superh machine?
Quoted 37 lines
Currently a failure in module load, or a module unload leaves a proc file registered, causing an oops in the event the proc file is read. This patch corrects that.
Thanks & Regards
NeilSigned-off-by Neil Horman <[email protected]>sq.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)arch/sh/kernel/cpu/sh4/sq.c +7
-1@@ -421,18 +421,27 @@ static struct miscdevice sq_dev = {static int __init sq_api_init (void ) { +int ret;printk (KERN_NOTICE "sq: Registering store queue API.\n" );#ifdef CONFIG_PROC_FS create_proc_read_entry ("sq_mapping" ,0 ,0 , sq_mapping_read_proc,0 );#endif -return misc_register (&sq_dev); + ret =misc_register (&sq_dev); +#ifdef CONFIG_PROC_FS +if (ret) +remove_proc_entry ("sq_mapping" ,NULL ); +#endif +return ret; }
arch/sh/kernel/cpu/sh4/sq.c static struct miscdevice sq_dev = { · line 447
Quoted 10 lines
arch/sh/kernel/cpu/sh4/sq.c +3
-0static void __exit sq_api_exit(void) {misc_deregister (&sq_dev); +#ifdef CONFIG_PROC_FS +remove_proc_entry ("sq_mapping" ,NULL ); +#endif }module_init (sq_api_init);
OK. But we do have a stub which provides a CONFIG_PROC_FS=n implementation of remove_proc_entry(), so the ifdefs shouldn't be necessary?
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [PATCH] sh: fix proc file removal for superh store queue module
Patch to clean up proc file removal in sq module for superh arch. currently on a failed module load or on module unload a proc file is left registered which can cause a random memory execution or oopses if read after unload. This patch cleans up that deregistration.
Thanks & Regards
Neil
sq.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
arch/sh/kernel/cpu/sh4/sq.c +7 -3
@@ -421,18 +421,22 @@ static struct miscdevice sq_dev = {static int __init sq_api_init (void ) { +int ret;printk (KERN_NOTICE "sq: Registering store queue API.\n" ); -#ifdef CONFIG_PROC_FS create_proc_read_entry ("sq_mapping" ,0 ,0 , sq_mapping_read_proc,0 ); -#endif -return misc_register (&sq_dev); + ret =misc_register (&sq_dev); +if (ret) +remove_proc_entry ("sq_mapping" ,NULL ); + +return ret; } static void __exit sq_api_exit(void) {misc_deregister (&sq_dev); +remove_proc_entry ("sq_mapping" ,NULL ); }module_init (sq_api_init);
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Paul Mundt
Acked-byRe: [linuxsh-dev] [PATCH] sh: fix proc file removal for superh store queue module
Quoted 5 lines · Neil Horman
Patch to clean up proc file removal in sq module for superh arch. currently on a failed module load or on module unload a proc file is left registered which can cause a random memory execution or oopses if read after unload. This patch cleans up that deregistration.
Looks good, thanks Neil.
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Re: [KJ] [KJ PATCH] sh: fix proc file removal for superh store
In reply to Neil HormanQuoted 6 lines · Andrew Morton
Quoted 2 lines
An oops fix isn't a kernel-janitors thing. It's a slam-it-into-mainline-and-consider-a-backport thing.
sorry, I was looking for more misc_register cleanups for KJ, and ran into this in the process. Wrote the email without thinking about the subject tags, my bad.
Quoted 7 lines
Quoted 1 line · On Thu, 3 Aug 2006 15:18:28 -0400 Neil Horman <[email protected]> wrote:
Patch to balance proc file creation and removal for superh store queue module.
You have a superh machine?
No, but the problem is fairly self evident. leaving a proc file dangling on module removal is begging to execute random data.
Quoted 3 lines
OK. But we do have a stub which provides a
CONFIG_PROC_FS=nimplementation ofremove_proc_entry(), so the ifdefs shouldn't be necessary?
Good point, I'll remove, and repost.
Neil
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors