提交 7a7a5c33 编写于 作者: J Jiri Slaby 提交者: Linus Torvalds

[PATCH] char: mxser_new, check request_region retvals

mxser_new, check request_region retvals

Return values of (pci_)request_region should be checked and error should be
returned if something is in bad state.
Signed-off-by: NJiri Slaby <jirislaby@gmail.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 59628015
...@@ -622,19 +622,24 @@ static int __init mxser_get_PCI_conf(int board_type, struct mxser_board *brd, ...@@ -622,19 +622,24 @@ static int __init mxser_get_PCI_conf(int board_type, struct mxser_board *brd,
{ {
unsigned int i, j; unsigned int i, j;
unsigned long ioaddress; unsigned long ioaddress;
int retval;
/* io address */ /* io address */
brd->board_type = board_type; brd->board_type = board_type;
brd->nports = mxser_numports[board_type - 1]; brd->nports = mxser_numports[board_type - 1];
ioaddress = pci_resource_start(pdev, 2); ioaddress = pci_resource_start(pdev, 2);
pci_request_region(pdev, 2, "mxser(IO)"); retval = pci_request_region(pdev, 2, "mxser(IO)");
if (retval)
goto err;
for (i = 0; i < brd->nports; i++) for (i = 0; i < brd->nports; i++)
brd->ports[i].ioaddr = ioaddress + 8 * i; brd->ports[i].ioaddr = ioaddress + 8 * i;
/* vector */ /* vector */
ioaddress = pci_resource_start(pdev, 3); ioaddress = pci_resource_start(pdev, 3);
pci_request_region(pdev, 3, "mxser(vector)"); retval = pci_request_region(pdev, 3, "mxser(vector)");
if (retval)
goto err_relio;
brd->vector = ioaddress; brd->vector = ioaddress;
/* irq */ /* irq */
...@@ -674,6 +679,10 @@ static int __init mxser_get_PCI_conf(int board_type, struct mxser_board *brd, ...@@ -674,6 +679,10 @@ static int __init mxser_get_PCI_conf(int board_type, struct mxser_board *brd,
brd->ports[i].baud_base = 921600; brd->ports[i].baud_base = 921600;
} }
return 0; return 0;
err_relio:
pci_release_region(pdev, 2);
err:
return retval;
} }
static int __init mxser_init(void) static int __init mxser_init(void)
...@@ -3009,8 +3018,12 @@ static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd) ...@@ -3009,8 +3018,12 @@ static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd)
brd->nports = 8; brd->nports = 8;
else else
brd->nports = 4; brd->nports = 4;
request_region(brd->ports[0].ioaddr, 8 * brd->nports, "mxser(IO)"); if (!request_region(brd->ports[0].ioaddr, 8 * brd->nports, "mxser(IO)"))
request_region(brd->vector, 1, "mxser(vector)"); return MXSER_ERR_IOADDR;
if (!request_region(brd->vector, 1, "mxser(vector)")) {
release_region(brd->ports[0].ioaddr, 8 * brd->nports);
return MXSER_ERR_VECTOR;
}
return brd->nports; return brd->nports;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册