From: Richard <h.vanberkum@chello.nl>
To: kernel-janitors@vger.kernel.org
Subject: [KJ] [PATCH] drivers/char/mxser.c: check request_region()
Date: Mon, 03 Jul 2006 22:52:52 +0000 [thread overview]
Message-ID: <44A9BD91.4010002@chello.nl> (raw)
Check return value of request_region and release already requested region if the
second fails
Signed-of-by: Richard van Berkum
--- 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
next reply other threads:[~2006-07-03 22:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-03 22:52 Richard [this message]
2006-07-03 23:12 ` [KJ] [PATCH] drivers/char/mxser.c: check request_region() Randy.Dunlap
2006-07-03 23:30 ` Richard
2006-07-04 0:01 ` Richard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44A9BD91.4010002@chello.nl \
--to=h.vanberkum@chello.nl \
--cc=kernel-janitors@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.