All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tim Cooijmans <tim@aapopfiets.nl>
To: kernel-janitors@vger.kernel.org
Subject: [KJ] [PATCH] check request_region return value
Date: Sat, 25 Feb 2006 13:58:20 +0000	[thread overview]
Message-ID: <200602251458.21105.tim@aapopfiets.nl> (raw)
In-Reply-To: <200602242249.22568.tim@aapopfiets.nl>

From: Tim Cooijmans <tim@aapopfiets.nl>

Check request_region return value in drivers/acpi/motherboard.c.  
acpi_reserve_resources now returns int, 0 being success.  
acpi_motherboard_init propagates that return value.

Passed compilation.

Signed-off-by: Tim Cooijmans <tim@aapopfiets.nl>
---
--- linux-2.6.16-rc4-orig/drivers/acpi/motherboard.c	2006-02-21 
20:18:41.000000000 +0100
+++ linux-2.6.16-rc4/drivers/acpi/motherboard.c	2006-02-25 14:08:01.000000000 
+0100
@@ -123,42 +123,115 @@ static struct acpi_driver acpi_motherboa
 		},
 };
 
-static void __init acpi_reserve_resources(void)
+static int __init acpi_reserve_resources(void)
 {
 	if (acpi_gbl_FADT->xpm1a_evt_blk.address && acpi_gbl_FADT->pm1_evt_len)
-		request_region(acpi_gbl_FADT->xpm1a_evt_blk.address,
-			       acpi_gbl_FADT->pm1_evt_len, "PM1a_EVT_BLK");
+		if (request_region(acpi_gbl_FADT->xpm1a_evt_blk.address,
+				   acpi_gbl_FADT->pm1_evt_len,
+				   "PM1a_EVT_BLK") = NULL) {
+			printk(KERN_WARNING "acpi_reserve_resources: could not"
+					    "allocate PM1a_EVT_BLK region\n");
+			goto out_pm1a_evt_blk;
+		}
 
 	if (acpi_gbl_FADT->xpm1b_evt_blk.address && acpi_gbl_FADT->pm1_evt_len)
-		request_region(acpi_gbl_FADT->xpm1b_evt_blk.address,
-			       acpi_gbl_FADT->pm1_evt_len, "PM1b_EVT_BLK");
+		if (request_region(acpi_gbl_FADT->xpm1b_evt_blk.address,
+				   acpi_gbl_FADT->pm1_evt_len,
+				   "PM1b_EVT_BLK") = NULL) {
+			printk(KERN_WARNING "acpi_reserve_resources: could not"
+					    "allocate PM1b_EVT_BLK region\n");
+			goto out_pm1b_evt_blk;
+		}
 
 	if (acpi_gbl_FADT->xpm1a_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len)
-		request_region(acpi_gbl_FADT->xpm1a_cnt_blk.address,
-			       acpi_gbl_FADT->pm1_cnt_len, "PM1a_CNT_BLK");
+		if (request_region(acpi_gbl_FADT->xpm1a_cnt_blk.address,
+				   acpi_gbl_FADT->pm1_cnt_len,
+				   "PM1a_CNT_BLK") = NULL) {
+			printk(KERN_WARNING "acpi_reserve_resources: could not"
+					    "allocate PM1a_CNT_BLK region\n");
+			goto out_pm1a_cnt_blk;
+		}
 
 	if (acpi_gbl_FADT->xpm1b_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len)
-		request_region(acpi_gbl_FADT->xpm1b_cnt_blk.address,
-			       acpi_gbl_FADT->pm1_cnt_len, "PM1b_CNT_BLK");
+		if (request_region(acpi_gbl_FADT->xpm1b_cnt_blk.address,
+				   acpi_gbl_FADT->pm1_cnt_len,
+				   "PM1b_CNT_BLK") = NULL) {
+			printk(KERN_WARNING "acpi_reserve_resources: could not"
+					    "allocate PM1b_CNT_BLK region\n");
+			goto out_pm1b_cnt_blk;
+		}
 
 	if (acpi_gbl_FADT->xpm_tmr_blk.address && acpi_gbl_FADT->pm_tm_len = 4)
-		request_region(acpi_gbl_FADT->xpm_tmr_blk.address, 4, "PM_TMR");
+		if (request_region(acpi_gbl_FADT->xpm_tmr_blk.address, 4,
+				   "PM_TMR") = NULL) {
+			printk(KERN_WARNING "acpi_reserve_resources: could not"
+					    "allocate PM_TMR region\n");
+			goto out_pm_tmr;
+		}
 
 	if (acpi_gbl_FADT->xpm2_cnt_blk.address && acpi_gbl_FADT->pm2_cnt_len)
-		request_region(acpi_gbl_FADT->xpm2_cnt_blk.address,
-			       acpi_gbl_FADT->pm2_cnt_len, "PM2_CNT_BLK");
+		if (request_region(acpi_gbl_FADT->xpm2_cnt_blk.address,
+				   acpi_gbl_FADT->pm2_cnt_len,
+				   "PM2_CNT_BLK") = NULL) {
+			printk(KERN_WARNING "acpi_reserve_resources: could not"
+					    "allocate PM2_CNT_BLK region\n");
+			goto out_pm2_cnt_blk;
+		}
 
 	/* Length of GPE blocks must be a non-negative multiple of 2 */
 
 	if (acpi_gbl_FADT->xgpe0_blk.address && acpi_gbl_FADT->gpe0_blk_len &&
 	    !(acpi_gbl_FADT->gpe0_blk_len & 0x1))
-		request_region(acpi_gbl_FADT->xgpe0_blk.address,
-			       acpi_gbl_FADT->gpe0_blk_len, "GPE0_BLK");
+		if (request_region(acpi_gbl_FADT->xgpe0_blk.address,
+				   acpi_gbl_FADT->gpe0_blk_len,
+				   "GPE0_BLK") = NULL) {
+			printk(KERN_WARNING "acpi_reserve_resources: could not"
+					    "allocate GPE0_BLK region\n");
+			goto out_gpe0_blk;
+		}
 
 	if (acpi_gbl_FADT->xgpe1_blk.address && acpi_gbl_FADT->gpe1_blk_len &&
 	    !(acpi_gbl_FADT->gpe1_blk_len & 0x1))
-		request_region(acpi_gbl_FADT->xgpe1_blk.address,
-			       acpi_gbl_FADT->gpe1_blk_len, "GPE1_BLK");
+		if (request_region(acpi_gbl_FADT->xgpe1_blk.address,
+				   acpi_gbl_FADT->gpe1_blk_len,
+				   "GPE1_BLK") = NULL) {
+			printk(KERN_WARNING "acpi_reserve_resources: could not"
+					    "allocate GPE1_BLK region\n");
+			goto out_gpe1_blk;
+		}
+
+	return 0;
+
+out_gpe1_blk:
+	if (acpi_gbl_FADT->xgpe0_blk.address && acpi_gbl_FADT->gpe0_blk_len &&
+	    !(acpi_gbl_FADT->gpe0_blk_len & 0x1))
+		release_region(acpi_gbl_FADT->xgpe0_blk.address,
+			       acpi_gbl_FADT->gpe0_blk_len);
+out_gpe0_blk:
+	if (acpi_gbl_FADT->xpm2_cnt_blk.address && acpi_gbl_FADT->pm2_cnt_len)
+		release_region(acpi_gbl_FADT->xpm2_cnt_blk.address,
+			       acpi_gbl_FADT->pm2_cnt_len);
+out_pm2_cnt_blk:
+	if (acpi_gbl_FADT->xpm_tmr_blk.address && acpi_gbl_FADT->pm_tm_len = 4)
+		release_region(acpi_gbl_FADT->xpm_tmr_blk.address, 4);
+out_pm_tmr:
+	if (acpi_gbl_FADT->xpm1b_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len)
+		release_region(acpi_gbl_FADT->xpm1b_cnt_blk.address,
+			       acpi_gbl_FADT->pm1_cnt_len);
+out_pm1b_cnt_blk:
+	if (acpi_gbl_FADT->xpm1a_cnt_blk.address && acpi_gbl_FADT->pm1_cnt_len)
+		release_region(acpi_gbl_FADT->xpm1a_cnt_blk.address,
+			       acpi_gbl_FADT->pm1_cnt_len);
+out_pm1a_cnt_blk:
+	if (acpi_gbl_FADT->xpm1b_evt_blk.address && acpi_gbl_FADT->pm1_evt_len)
+		release_region(acpi_gbl_FADT->xpm1b_evt_blk.address,
+			       acpi_gbl_FADT->pm1_evt_len);
+out_pm1b_evt_blk:
+	if (acpi_gbl_FADT->xpm1a_evt_blk.address && acpi_gbl_FADT->pm1_evt_len)
+		release_region(acpi_gbl_FADT->xpm1a_evt_blk.address,
+			       acpi_gbl_FADT->pm1_evt_len);
+out_pm1a_evt_blk:
+	return -EBUSY;
 }
 
 static int __init acpi_motherboard_init(void)
@@ -170,7 +243,8 @@ static int __init acpi_motherboard_init(
 	 * This module must run after scan.c
 	 */
 	if (!acpi_disabled)
-		acpi_reserve_resources();
+		return acpi_reserve_resources();
+
 	return 0;
 }
 
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors

  parent reply	other threads:[~2006-02-25 13:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-24 21:49 [KJ] [PATCH] check request_region return value Tim Cooijmans
2006-02-24 21:58 ` Jesper Juhl
2006-02-24 23:07 ` Tim Cooijmans
2006-02-24 23:11 ` Jesper Juhl
2006-02-25 13:58 ` Tim Cooijmans [this message]
2006-02-25 14:13 ` Jesper Juhl
2006-02-25 17:26 ` Tim Cooijmans
2006-02-25 17:34 ` Jesper Juhl
2006-02-25 20:42 ` Tim Cooijmans
2006-02-25 21:03 ` Jesper Juhl
2006-02-26  4:50 ` Darren Jenkins\
2006-02-26 19:52 ` Tim Cooijmans

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=200602251458.21105.tim@aapopfiets.nl \
    --to=tim@aapopfiets.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.