mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vasiliy Kulikov <segooon@gmail.com>
To: kernel-janitors@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, Daniel Drake <dsd@laptop.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] x86: kernel: olpc-xo1: fix error handling code
Date: Sun, 17 Oct 2010 18:51:46 +0400	[thread overview]
Message-ID: <1287327106-9111-1-git-send-email-segooon@gmail.com> (raw)

If anything failed during initialization then setup_bases() should
call pci_disable_device().  Also reference got from pci_get_device()
should be freed with pci_dev_put().

Signed-off-by: Vasiliy Kulikov <segooon@gmail.com>
---
 arch/x86/kernel/olpc-xo1.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/olpc-xo1.c b/arch/x86/kernel/olpc-xo1.c
index f5442c0..05331cf 100644
--- a/arch/x86/kernel/olpc-xo1.c
+++ b/arch/x86/kernel/olpc-xo1.c
@@ -71,20 +71,25 @@ static int __devinit setup_bases(struct pci_dev *pdev)
 	r = pci_request_region(pdev, ACPI_BAR, DRV_NAME);
 	if (r) {
 		dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", ACPI_BAR);
-		return r;
+		goto err_disable;
 	}
 
 	r = pci_request_region(pdev, PMS_BAR, DRV_NAME);
 	if (r) {
 		dev_err(&pdev->dev, "can't alloc PCI BAR #%d\n", PMS_BAR);
-		pci_release_region(pdev, ACPI_BAR);
-		return r;
+		goto err_region1;
 	}
 
 	acpi_base = pci_resource_start(pdev, ACPI_BAR);
 	pms_base = pci_resource_start(pdev, PMS_BAR);
 
 	return 0;
+
+err_region1:
+	pci_release_region(pdev, ACPI_BAR);
+err_disable:
+	pci_disable_device(pdev);
+	return r;
 }
 
 static int __devinit olpc_xo1_probe(struct platform_device *pdev)
@@ -98,6 +103,7 @@ static int __devinit olpc_xo1_probe(struct platform_device *pdev)
 		return -ENODEV;
 
 	r = setup_bases(pcidev);
+	pci_dev_put(pcidev);
 	if (r)
 		return r;
 
-- 
1.7.0.4


                 reply	other threads:[~2010-10-17 14:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1287327106-9111-1-git-send-email-segooon@gmail.com \
    --to=segooon@gmail.com \
    --cc=dsd@laptop.org \
    --cc=hpa@zytor.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome