linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* PATCH: SBC EPX does not check/claim I/O ports it uses
@ 2006-01-17 17:52 Alan Cox
  2006-01-17 18:03 ` Bartlomiej Zolnierkiewicz
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Cox @ 2006-01-17 17:52 UTC (permalink / raw)
  To: calin, linux-kernel, akpm

Signed-off-by: Alan Cox <alan@redhat.com>

Can't test this as I lack the hardware, can you check it seems right
Calin.

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.16-rc1/drivers/char/watchdog/sbc_epx_c3.c linux-2.6.16-rc1/drivers/char/watchdog/sbc_epx_c3.c
--- linux.vanilla-2.6.16-rc1/drivers/char/watchdog/sbc_epx_c3.c	2006-01-17 15:52:53.000000000 +0000
+++ linux-2.6.16-rc1/drivers/char/watchdog/sbc_epx_c3.c	2006-01-17 15:58:47.000000000 +0000
@@ -25,6 +25,7 @@
 #include <linux/notifier.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
+#include <linux/ioport.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
@@ -180,6 +181,9 @@
 static int __init watchdog_init(void)
 {
 	int ret;
+	
+	if (!request_region(EPXC3_WATCHDOG_CTL_REG, 2, "epxc3_watchdog"))
+		return -EBUSY;
 
 	ret = register_reboot_notifier(&epx_c3_notifier);
 	if (ret) {
@@ -205,6 +209,7 @@
 {
 	misc_deregister(&epx_c3_miscdev);
 	unregister_reboot_notifier(&epx_c3_notifier);
+	release_region(EPXC3_WATCHDOG_CTL_REG, 2);
 }
 
 module_init(watchdog_init);


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: SBC EPX does not check/claim I/O ports it uses
  2006-01-17 17:52 PATCH: SBC EPX does not check/claim I/O ports it uses Alan Cox
@ 2006-01-17 18:03 ` Bartlomiej Zolnierkiewicz
  2006-01-17 18:09   ` Alan Cox
  2006-01-17 18:42   ` PATCH: SBC EPX does not check/claim I/O ports it uses (2nd Edition) Alan Cox
  0 siblings, 2 replies; 6+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2006-01-17 18:03 UTC (permalink / raw)
  To: Alan Cox; +Cc: calin, linux-kernel, akpm

Hi,

> @@ -180,6 +181,9 @@
>  static int __init watchdog_init(void)
>  {
>         int ret;
> +
> +       if (!request_region(EPXC3_WATCHDOG_CTL_REG, 2, "epxc3_watchdog"))
> +               return -EBUSY;
>
>         ret = register_reboot_notifier(&epx_c3_notifier);
>         if (ret) {

Shouldn't resource be released when
register_reboot_notifier() or misc_register() fails?

Bartlomiej

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: SBC EPX does not check/claim I/O ports it uses
  2006-01-17 18:03 ` Bartlomiej Zolnierkiewicz
@ 2006-01-17 18:09   ` Alan Cox
  2006-01-17 18:42   ` PATCH: SBC EPX does not check/claim I/O ports it uses (2nd Edition) Alan Cox
  1 sibling, 0 replies; 6+ messages in thread
From: Alan Cox @ 2006-01-17 18:09 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: calin, linux-kernel, akpm

On Maw, 2006-01-17 at 19:03 +0100, Bartlomiej Zolnierkiewicz wrote:
> >         ret = register_reboot_notifier(&epx_c3_notifier);
> >         if (ret) {
> 
> Shouldn't resource be released when
> register_reboot_notifier() or misc_register() fails?

Yes, let me insert my brain and post a corrected patch.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* PATCH: SBC EPX does not check/claim I/O ports it uses (2nd Edition)
  2006-01-17 18:03 ` Bartlomiej Zolnierkiewicz
  2006-01-17 18:09   ` Alan Cox
@ 2006-01-17 18:42   ` Alan Cox
  2006-01-18 12:10     ` Jiri Slaby
  1 sibling, 1 reply; 6+ messages in thread
From: Alan Cox @ 2006-01-17 18:42 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz; +Cc: calin, linux-kernel, akpm

Signed-off-by: Alan Cox <alan@redhat.com>

--- linux.vanilla-2.6.16-rc1/drivers/char/watchdog/sbc_epx_c3.c	2006-01-17 15:52:53.000000000 +0000
+++ linux-2.6.16-rc1/drivers/char/watchdog/sbc_epx_c3.c	2006-01-17 18:27:39.149607944 +0000
@@ -25,6 +25,7 @@
 #include <linux/notifier.h>
 #include <linux/reboot.h>
 #include <linux/init.h>
+#include <linux/ioport.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
 
@@ -180,12 +181,15 @@
 static int __init watchdog_init(void)
 {
 	int ret;
+	
+	if (!request_region(EPXC3_WATCHDOG_CTL_REG, 2, "epxc3_watchdog"))
+		return -EBUSY;
 
 	ret = register_reboot_notifier(&epx_c3_notifier);
 	if (ret) {
 		printk(KERN_ERR PFX "cannot register reboot notifier "
 			"(err=%d)\n", ret);
-		return ret;
+		goto out;
 	}
 
 	ret = misc_register(&epx_c3_miscdev);
@@ -193,12 +197,16 @@
 		printk(KERN_ERR PFX "cannot register miscdev on minor=%d "
 			"(err=%d)\n", WATCHDOG_MINOR, ret);
 		unregister_reboot_notifier(&epx_c3_notifier);
-		return ret;
+		goto out;
 	}
 
 	printk(banner);
 
 	return 0;
+
+out:
+	release_region(EPXC3_WATCHDOG_CTL_REG, 2);
+	return ret;
 }
 
 static void __exit watchdog_exit(void)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: SBC EPX does not check/claim I/O ports it uses (2nd Edition)
  2006-01-17 18:42   ` PATCH: SBC EPX does not check/claim I/O ports it uses (2nd Edition) Alan Cox
@ 2006-01-18 12:10     ` Jiri Slaby
  2006-01-18 12:20       ` Andrew Morton
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Slaby @ 2006-01-18 12:10 UTC (permalink / raw)
  To: Alan Cox; +Cc: Bartlomiej Zolnierkiewicz, calin, linux-kernel, akpm

Alan Cox wrote:
>Signed-off-by: Alan Cox <alan@redhat.com>
>
>--- linux.vanilla-2.6.16-rc1/drivers/char/watchdog/sbc_epx_c3.c	2006-01-17 15:52:53.000000000 +0000
>+++ linux-2.6.16-rc1/drivers/char/watchdog/sbc_epx_c3.c	2006-01-17 18:27:39.149607944 +0000
>@@ -25,6 +25,7 @@
> #include <linux/notifier.h>
> #include <linux/reboot.h>
> #include <linux/init.h>
>+#include <linux/ioport.h>
> #include <asm/uaccess.h>
> #include <asm/io.h>
> 
>@@ -180,12 +181,15 @@
> static int __init watchdog_init(void)
> {
> 	int ret;
>+	
>+	if (!request_region(EPXC3_WATCHDOG_CTL_REG, 2, "epxc3_watchdog"))
>+		return -EBUSY;
> 
> 	ret = register_reboot_notifier(&epx_c3_notifier);
> 	if (ret) {
> 		printk(KERN_ERR PFX "cannot register reboot notifier "
> 			"(err=%d)\n", ret);
>-		return ret;
>+		goto out;
> 	}
> 
> 	ret = misc_register(&epx_c3_miscdev);
>@@ -193,12 +197,16 @@
> 		printk(KERN_ERR PFX "cannot register miscdev on minor=%d "
> 			"(err=%d)\n", WATCHDOG_MINOR, ret);
> 		unregister_reboot_notifier(&epx_c3_notifier);
>-		return ret;
>+		goto out;
> 	}
> 
> 	printk(banner);
> 
> 	return 0;
>+
>+out:
>+	release_region(EPXC3_WATCHDOG_CTL_REG, 2);
>+	return ret;
> }
> 
> static void __exit watchdog_exit(void)
But now, you forgot to add release_region in this (exit) function :)?

regards,
-- 
Jiri Slaby         www.fi.muni.cz/~xslaby
\_.-^-._   jirislaby@gmail.com   _.-^-._/
B67499670407CE62ACC8 22A032CC55C339D47A7E

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: SBC EPX does not check/claim I/O ports it uses (2nd Edition)
  2006-01-18 12:10     ` Jiri Slaby
@ 2006-01-18 12:20       ` Andrew Morton
  0 siblings, 0 replies; 6+ messages in thread
From: Andrew Morton @ 2006-01-18 12:20 UTC (permalink / raw)
  To: Jiri Slaby; +Cc: alan, bzolnier, calin, linux-kernel

"Jiri Slaby" <xslaby@fi.muni.cz> wrote:
>
> > static void __exit watchdog_exit(void)
>  But now, you forgot to add release_region in this (exit) function :)?

yup.  That'll give a nice oops reading /proc/ioports after rmmod...


--- devel/drivers/char/watchdog/sbc_epx_c3.c~sbc-epx-does-not-check-claim-i-o-ports-it-uses-2nd-edition-fix	2006-01-18 04:19:58.000000000 -0800
+++ devel-akpm/drivers/char/watchdog/sbc_epx_c3.c	2006-01-18 04:19:58.000000000 -0800
@@ -213,6 +213,7 @@ static void __exit watchdog_exit(void)
 {
 	misc_deregister(&epx_c3_miscdev);
 	unregister_reboot_notifier(&epx_c3_notifier);
+	release_region(EPXC3_WATCHDOG_CTL_REG, 2);
 }
 
 module_init(watchdog_init);
_


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-01-18 12:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-17 17:52 PATCH: SBC EPX does not check/claim I/O ports it uses Alan Cox
2006-01-17 18:03 ` Bartlomiej Zolnierkiewicz
2006-01-17 18:09   ` Alan Cox
2006-01-17 18:42   ` PATCH: SBC EPX does not check/claim I/O ports it uses (2nd Edition) Alan Cox
2006-01-18 12:10     ` Jiri Slaby
2006-01-18 12:20       ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).