Commit 757be186129b674e3a0146a4bc1861ed0744cd95

Authored by Neil Horman
Committed by Linus Torvalds
1 parent 453c3e478e

[PATCH] sh: fix proc file removal for superh store queue module

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.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Paul Mundt <lethal@linux-sh.org>
Cc: Kazumoto Kojima <kkojima@rr.iij4u.or.jp>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

Showing 1 changed file with 7 additions and 3 deletions Side-by-side Diff

arch/sh/kernel/cpu/sh4/sq.c
... ... @@ -421,18 +421,22 @@
421 421  
422 422 static int __init sq_api_init(void)
423 423 {
  424 + int ret;
424 425 printk(KERN_NOTICE "sq: Registering store queue API.\n");
425 426  
426   -#ifdef CONFIG_PROC_FS
427 427 create_proc_read_entry("sq_mapping", 0, 0, sq_mapping_read_proc, 0);
428   -#endif
429 428  
430   - return misc_register(&sq_dev);
  429 + ret = misc_register(&sq_dev);
  430 + if (ret)
  431 + remove_proc_entry("sq_mapping", NULL);
  432 +
  433 + return ret;
431 434 }
432 435  
433 436 static void __exit sq_api_exit(void)
434 437 {
435 438 misc_deregister(&sq_dev);
  439 + remove_proc_entry("sq_mapping", NULL);
436 440 }
437 441  
438 442 module_init(sq_api_init);