drivers/char/mxser.c: check request_region()
Subsystems (3)
PATCH 1/1 drivers/char/mxser.c: check request_region()
Check return value of request_region and release already requested region if the second fails
Signed-of-by: Richard van Berkum
drivers/char/mxser.c +16 -4
@@ -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
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 4 lines · On Tue, 04 Jul 2006 03:00:01 +0200 Richard wrote:
Check return value of
request_regionand release already requested region if the second failsSigned-of-by: Richard van Berkum
Scripts want spelling to be: Signed-off-by
A few small style issues below:
drivers/char/mxser.c static int mxser_get_PCI_conf(int busnum · line 645
Quoted 9 lines
drivers/char/mxser.c +1
-2@@ -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"
drivers/char/mxser.c static int mxser_get_PCI_conf(int busnum · line 648
Quoted 3 lines
drivers/char/mxser.c +3
-0+ "mxser(IO)"))){ +printk (KERN_ERR "mxser: I/O ports already in use\n" ); +return (-EIO );
No parens around return values.
drivers/char/mxser.c static int mxser_get_PCI_conf(int busnum · line 657
Quoted 11 lines
drivers/char/mxser.c +3
-2+ } +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
Quoted 9 lines
drivers/char/mxser.c +5
-0+ "mxser(vector)"))){ +printk (KERN_ERR "mxser: I/O ports already in use\n" ); + goto out; + } + hwconf->vector = ioaddress;/* irq */
drivers/char/mxser.c static int mxser_get_PCI_conf(int busnum · line 704
Quoted 6 lines
drivers/char/mxser.c +3
-0@@ -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.
drivers/char/mxser.c static int mxser_get_PCI_conf(int busnum · line 707
Quoted 3 lines
drivers/char/mxser.c +1
-0+ }#endif
---
~Randy
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Randy.Dunlap wrote:
Hello Randy,
Quoted 3 lines
Quoted 3 lines · On Tue, 04 Jul 2006 03:00:01 +0200 Richard wrote:
Quoted 2 lines
Quoted 2 lines
Check return value of
request_regionand release already requested region
if the
Quoted 5 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
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
drivers/char/mxser.c +16 -4
@@ -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
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
Quoted 1 line · Randy.Dunlap
Thanks... but I missed one more: use space before '{'
Okay
Quoted 2 lines
And send it to the mailing list...
I did resend it later when I realized I forgot the mailing list
Quoted 1 line
drivers/char/mxser.c +16 -4
@@ -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
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors