* Re: [KJ] [PATCH] drivers/char/mxser.c: check request_region()
2006-07-03 22:52 [KJ] [PATCH] drivers/char/mxser.c: check request_region() Richard
@ 2006-07-03 23:12 ` Randy.Dunlap
2006-07-03 23:30 ` Richard
2006-07-04 0:01 ` Richard
2 siblings, 0 replies; 4+ messages in thread
From: Randy.Dunlap @ 2006-07-03 23:12 UTC (permalink / raw)
To: kernel-janitors
On Tue, 04 Jul 2006 03:00:01 +0200 Richard wrote:
> Check return value of request_region and release already requested region if the
> second fails
>
> Signed-of-by: Richard van Berkum
Scripts want spelling to be: Signed-off-by
A few small style issues below:
> --- janitor-2.6/drivers/char/mxser.c 2006-07-01 11:54:45.895077096 +0200
> +++ mytree/drivers/char/mxser.c 2006-07-04 02:52:17.965040344 +0200
> @@ -642,16 +642,24 @@ static int mxser_get_PCI_conf(int busnum
> hwconf->board_type = board_type;
> hwconf->ports = mxser_numports[board_type - 1];
> ioaddress = pci_resource_start(pdev, 2);
> - request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2),
> - "mxser(IO)");
> + if(!(request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2),
space after "if"
> + "mxser(IO)"))){
> + printk(KERN_ERR "mxser: I/O ports already in use\n");
> + return (-EIO);
No parens around return values.
> + }
> +
>
> for (i = 0; i < hwconf->ports; i++)
> hwconf->ioaddr[i] = ioaddress + 8 * i;
>
> /* vector */
> ioaddress = pci_resource_start(pdev, 3);
> - request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3),
> - "mxser(vector)");
> + if(!(request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3),
same as above
> + "mxser(vector)"))){
> + printk(KERN_ERR "mxser: I/O ports already in use\n");
> + goto out;
> + }
> +
> hwconf->vector = ioaddress;
>
> /* irq */
> @@ -691,6 +699,10 @@ static int mxser_get_PCI_conf(int busnum
> hwconf->baud_base[i] = 921600;
> }
> return 0;
> +out:
> + release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2));
> + return (-EIO);
no parens.
> +
> }
> #endif
---
~Randy
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [KJ] [PATCH] drivers/char/mxser.c: check request_region()
2006-07-03 22:52 [KJ] [PATCH] drivers/char/mxser.c: check request_region() Richard
2006-07-03 23:12 ` Randy.Dunlap
@ 2006-07-03 23:30 ` Richard
2006-07-04 0:01 ` Richard
2 siblings, 0 replies; 4+ messages in thread
From: Richard @ 2006-07-03 23:30 UTC (permalink / raw)
To: kernel-janitors
Randy.Dunlap wrote:
Hello Randy,
> > On Tue, 04 Jul 2006 03:00:01 +0200 Richard wrote:
> >
>> >> Check return value of request_region and release already requested region
if the
>> >> second fails
>> >>
>> >> Signed-of-by: Richard van Berkum
> >
> > Scripts want spelling to be: Signed-off-by
Okay, I'll add the emailadres to.
Thanks for the corrections
Signed-off-by: Richard van Berkum <h.vanberkum at chello.nl>
--- janitor-2.6/drivers/char/mxser.c 2006-07-01 11:54:45.895077096 +0200
+++ mytree/drivers/char/mxser.c 2006-07-04 02:52:17.965040344 +0200
@@ -642,16 +642,24 @@ static int mxser_get_PCI_conf(int busnum
hwconf->board_type = board_type;
hwconf->ports = mxser_numports[board_type - 1];
ioaddress = pci_resource_start(pdev, 2);
- request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2),
- "mxser(IO)");
+ if (!(request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2),
+ "mxser(IO)"))){
+ printk(KERN_ERR "mxser: I/O ports already in use\n");
+ return -EIO;
+ }
+
for (i = 0; i < hwconf->ports; i++)
hwconf->ioaddr[i] = ioaddress + 8 * i;
/* vector */
ioaddress = pci_resource_start(pdev, 3);
- request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3),
- "mxser(vector)");
+ if (!(request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3),
+ "mxser(vector)"))){
+ printk(KERN_ERR "mxser: I/O ports already in use\n");
+ goto out;
+ }
+
hwconf->vector = ioaddress;
/* irq */
@@ -691,6 +699,10 @@ static int mxser_get_PCI_conf(int busnum
hwconf->baud_base[i] = 921600;
}
return 0;
+out:
+ release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2));
+ return -EIO;
+
}
#endif
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [KJ] [PATCH] drivers/char/mxser.c: check request_region()
2006-07-03 22:52 [KJ] [PATCH] drivers/char/mxser.c: check request_region() Richard
2006-07-03 23:12 ` Randy.Dunlap
2006-07-03 23:30 ` Richard
@ 2006-07-04 0:01 ` Richard
2 siblings, 0 replies; 4+ messages in thread
From: Richard @ 2006-07-04 0:01 UTC (permalink / raw)
To: kernel-janitors
Randy.Dunlap wrote:
> Thanks... but I missed one more: use space before '{'
Okay
>
> And send it to the mailing list...
I did resend it later when I realized I forgot the mailing list
>
Signed-off-by: Richard van Berkum <h.vanberkum at chello.nl>
--- janitor-2.6/drivers/char/mxser.c 2006-07-01 11:54:45.895077096 +0200
+++ mytree/drivers/char/mxser.c 2006-07-04 02:52:17.965040344 +0200
@@ -642,16 +642,24 @@ static int mxser_get_PCI_conf(int busnum
hwconf->board_type = board_type;
hwconf->ports = mxser_numports[board_type - 1];
ioaddress = pci_resource_start(pdev, 2);
- request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2),
- "mxser(IO)");
+ if (!(request_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2),
+ "mxser(IO)"))) {
+ printk(KERN_ERR "mxser: I/O ports already in use\n");
+ return -EIO;
+ }
+
for (i = 0; i < hwconf->ports; i++)
hwconf->ioaddr[i] = ioaddress + 8 * i;
/* vector */
ioaddress = pci_resource_start(pdev, 3);
- request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3),
- "mxser(vector)");
+ if (!(request_region(pci_resource_start(pdev, 3), pci_resource_len(pdev, 3),
+ "mxser(vector)"))) {
+ printk(KERN_ERR "mxser: I/O ports already in use\n");
+ goto out;
+ }
+
hwconf->vector = ioaddress;
/* irq */
@@ -691,6 +699,10 @@ static int mxser_get_PCI_conf(int busnum
hwconf->baud_base[i] = 921600;
}
return 0;
+out:
+ release_region(pci_resource_start(pdev, 2), pci_resource_len(pdev, 2));
+ return -EIO;
+
}
#endif
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
^ permalink raw reply [flat|nested] 4+ messages in thread