From patchwork Fri Nov 9 09:19:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommi Rantala X-Patchwork-Id: 1719791 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id E547C3FCF7 for ; Fri, 9 Nov 2012 09:29:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BF773A0C12 for ; Fri, 9 Nov 2012 01:29:46 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wg0-f43.google.com (mail-wg0-f43.google.com [74.125.82.43]) by gabe.freedesktop.org (Postfix) with ESMTP id 84287A0BD4 for ; Fri, 9 Nov 2012 01:24:32 -0800 (PST) Received: by mail-wg0-f43.google.com with SMTP id dq11so1809636wgb.12 for ; Fri, 09 Nov 2012 01:24:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=p81ideKnzzUmqTKjBqS0w7V5lP3+nefnzvtCnlbiU7E=; b=maAhn611Hc9FSO/xGkc7xvHxFRb2VZuZauwiCI0eAps4Sp5kPN+Tr2UggXdaO19hA2 /hHgbMux3R4ATmiXK8r0Gh7LAjAeb2XD8+a3C9fBMFB8fygMFtJwgr2ELQmT/XnSXFDf rbCPly5cscffgiGOLVciGHcRJ1hh8uru+ca7C6vODAKevXqu3jueTzS2XUyyDOKplhVv eBMaOkU/CH93yG3M5ilz3KYYNqSqZQZLhivjttDaIlC1cvxCHrLUtOQO02onCN/i2B5y IgzeXHdVGYU6YmKnlhQwoR3jXkGLHRZx4FhVzngdVEvwUa8vqJWkewCu38q8FKoy2NiI SrRQ== Received: by 10.216.194.38 with SMTP id l38mr4415751wen.80.1352453072302; Fri, 09 Nov 2012 01:24:32 -0800 (PST) Received: from localhost.localdomain (espcolo-webproxy02.nokia.com. [192.100.120.42]) by mx.google.com with ESMTPS id r10sm1560293wiz.0.2012.11.09.01.24.31 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 09 Nov 2012 01:24:31 -0800 (PST) From: Tommi Rantala To: David Airlie , dri-devel@lists.freedesktop.org Subject: [PATCH 5/6] drm/radeon: check alloc_apertures() success in radeon_kick_out_firmware_fb() Date: Fri, 9 Nov 2012 11:19:39 +0200 Message-Id: <1352452780-2029-6-git-send-email-tt.rantala@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1352452780-2029-1-git-send-email-tt.rantala@gmail.com> References: <1352452780-2029-1-git-send-email-tt.rantala@gmail.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Check for alloc_apertures() memory allocation failure, and propagate an error code in case the allocation failed. Signed-off-by: Tommi Rantala --- drivers/gpu/drm/radeon/radeon_drv.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index 07eb84e..8c1a83c 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -281,12 +281,15 @@ static struct drm_driver driver_old = { static struct drm_driver kms_driver; -static void radeon_kick_out_firmware_fb(struct pci_dev *pdev) +static int radeon_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); @@ -295,13 +298,19 @@ static void radeon_kick_out_firmware_fb(struct pci_dev *pdev) #endif remove_conflicting_framebuffers(ap, "radeondrmfb", primary); kfree(ap); + + return 0; } static int __devinit radeon_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { + int ret; + /* Get rid of things like offb */ - radeon_kick_out_firmware_fb(pdev); + ret = radeon_kick_out_firmware_fb(pdev); + if (ret) + return ret; return drm_get_pci_dev(pdev, ent, &kms_driver); }