dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Tommi Rantala <tt.rantala@gmail.com>
To: David Airlie <airlied@linux.ie>, dri-devel@lists.freedesktop.org
Subject: [PATCH 1/6] drm/cirrus: check alloc_apertures() success in cirrus_kick_out_firmware_fb()
Date: Fri,  9 Nov 2012 11:19:35 +0200	[thread overview]
Message-ID: <1352452780-2029-2-git-send-email-tt.rantala@gmail.com> (raw)
In-Reply-To: <1352452780-2029-1-git-send-email-tt.rantala@gmail.com>

Check for alloc_apertures() memory allocation failure, and propagate an
error code in case the allocation failed.

Signed-off-by: Tommi Rantala <tt.rantala@gmail.com>
---
 drivers/gpu/drm/cirrus/cirrus_drv.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c
index 101e423..dcd1a8c 100644
--- a/drivers/gpu/drm/cirrus/cirrus_drv.c
+++ b/drivers/gpu/drm/cirrus/cirrus_drv.c
@@ -35,12 +35,15 @@ static DEFINE_PCI_DEVICE_TABLE(pciidlist) = {
 };
 
 
-static void cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
+static int cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
 {
 	struct apertures_struct *ap;
 	bool primary = false;
 
 	ap = alloc_apertures(1);
+	if (!ap)
+		return -ENOMEM;
+
 	ap->ranges[0].base = pci_resource_start(pdev, 0);
 	ap->ranges[0].size = pci_resource_len(pdev, 0);
 
@@ -49,12 +52,18 @@ static void cirrus_kick_out_firmware_fb(struct pci_dev *pdev)
 #endif
 	remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary);
 	kfree(ap);
+
+	return 0;
 }
 
 static int __devinit
 cirrus_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 {
-	cirrus_kick_out_firmware_fb(pdev);
+	int ret;
+
+	ret = cirrus_kick_out_firmware_fb(pdev);
+	if (ret)
+		return ret;
 
 	return drm_get_pci_dev(pdev, ent, &driver);
 }
-- 
1.7.9.5

  reply	other threads:[~2012-11-09  9:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-09  9:19 [PATCH 0/6] alloc_apertures() handling fixes Tommi Rantala
2012-11-09  9:19 ` Tommi Rantala [this message]
2012-11-09  9:19 ` [PATCH 2/6] drm/mgag200: check alloc_apertures() success in mga_vram_init() Tommi Rantala
2012-11-09  9:19 ` [PATCH 3/6] drm/mgag200: free memory allocated with alloc_apertures() Tommi Rantala
2012-11-09  9:19 ` [PATCH 4/6] drm/mgag200: remove unneeded aper->count assignment after alloc_apertures() Tommi Rantala
2012-11-09  9:19 ` [PATCH 5/6] drm/radeon: check alloc_apertures() success in radeon_kick_out_firmware_fb() Tommi Rantala
2012-11-09  9:19 ` [PATCH 6/6] drm/nouveau: free memory allocated with alloc_apertures() Tommi Rantala

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=1352452780-2029-2-git-send-email-tt.rantala@gmail.com \
    --to=tt.rantala@gmail.com \
    --cc=airlied@linux.ie \
    --cc=dri-devel@lists.freedesktop.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