From patchwork Fri Nov 9 09:19:35 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tommi Rantala X-Patchwork-Id: 1719751 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 606693FCF7 for ; Fri, 9 Nov 2012 09:26:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A798A0C1D for ; Fri, 9 Nov 2012 01:26:26 -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 2084EA0B9A for ; Fri, 9 Nov 2012 01:24:28 -0800 (PST) Received: by mail-wg0-f43.google.com with SMTP id dq11so1809636wgb.12 for ; Fri, 09 Nov 2012 01:24:28 -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=XzY/utmFHW2GFQx5w5Wb4SPTwKLCb1gqPHtjlec4fsY=; b=GqyRGwdf2uZm9klIH8BNxxsvI8wXlohA/IP5k26rn0WgLWYM5z2QHjZ7J1kW1SqTlf yQICLj5B/uG6YvVWiUmUrig4xab7lBAjb/lrHLy6aSl+cAUs+E82tEt59QHFmtYqgpk3 rDX3Z6KHsL2U6O4r0jAOmXFaoYGtLIF5CkJqZEQv9gde7CLgfSJS1K2hO4Jv2Z96UhCX db+CDWqj/HC7beVlDXTJxIRJJIQyvHFg5cCyT6bCL9CTjQpAOKLDazyrxsEXzvEywHaa UDkEqBw7Kd0vzu51XuhdKH0Hvv01DH6USQ6lA7LMlueSrACieE7oemS5yGXHO3h6ThEa NWwg== Received: by 10.180.92.132 with SMTP id cm4mr1506968wib.12.1352453068435; Fri, 09 Nov 2012 01:24:28 -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.27 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 09 Nov 2012 01:24:28 -0800 (PST) From: Tommi Rantala To: David Airlie , 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 Message-Id: <1352452780-2029-2-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/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); }