From patchwork Sat Oct 20 10:32:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 1621051 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 2028C40135 for ; Sat, 20 Oct 2012 10:39:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1C54A9E957 for ; Sat, 20 Oct 2012 03:39:16 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.187]) by gabe.freedesktop.org (Postfix) with ESMTP id E2DEE9E8D3 for ; Sat, 20 Oct 2012 03:38:14 -0700 (PDT) Received: from mailbox.adnet.avionic-design.de (mailbox.avionic-design.de [109.75.18.3]) by mrelayeu.kundenserver.de (node=mreu0) with ESMTP (Nemesis) id 0MVHuk-1TwwBo3cb8-00YCil; Sat, 20 Oct 2012 12:32:59 +0200 Received: from localhost (localhost [127.0.0.1]) by mailbox.adnet.avionic-design.de (Postfix) with ESMTP id 3F7072A28320; Sat, 20 Oct 2012 12:32:58 +0200 (CEST) X-Virus-Scanned: amavisd-new at avionic-design.de Received: from mailbox.adnet.avionic-design.de ([127.0.0.1]) by localhost (mailbox.avionic-design.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id x8U18SVgpOwp; Sat, 20 Oct 2012 12:32:57 +0200 (CEST) Received: from localhost (avionic-0098.adnet.avionic-design.de [172.20.31.233]) (Authenticated sender: thierry.reding) by mailbox.adnet.avionic-design.de (Postfix) with ESMTPA id 67F282A282B0; Sat, 20 Oct 2012 12:32:57 +0200 (CEST) From: Thierry Reding To: David Airlie Subject: [PATCH 2/2] drm: fb: cma: Fail gracefully on allocation failure Date: Sat, 20 Oct 2012 12:32:47 +0200 Message-Id: <1350729172-12506-2-git-send-email-thierry.reding@avionic-design.de> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1350729172-12506-1-git-send-email-thierry.reding@avionic-design.de> References: <1350729172-12506-1-git-send-email-thierry.reding@avionic-design.de> X-Provags-ID: V02:K0:sXdiJE8S0F3OM8x7OgyV9Tn+R24RipFjsjKrec1P7wS C/jWGD4azYJvFxQUvBZaa5txTmfPOZ5Qrvg79VEbvvQAdWht5f Eo7duB0c9FytbWbDHEcSBZ/9S0ODBlx2J0xS5VcRddAQgKIQNI mDOCqmbG6XHHiu27h/XT/G9/XhKv2VkC6ETzF3xEnyG4Bnt3Tz OgEzjsoRvctPgAPzSbFHWRsMlyaIknI5QJjEq7Imx4qTtR0rjS CSNEC5zyL6C8myHxkqtKRn/yq1qFOCKn6LCUJ30yRJIvOF5IVq MNAmvVMmFF8cpSehZDD/00Kw4mlWDrAFKfMVAqJOYJA8lsAQWT xDddwGb0SXLKVcE4wT81IeB4AoJG6u0XdFHyG6e49wdZkIGRZr jV5OjB8DT18+3dfIUnazOcJG6dSIcnzBeEN9zWzdhI/sGB2sS9 0B0rV Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Laurent Pinchart 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 The drm_gem_cma_create() function never returns NULL but rather an error encoded in the return value using the ERR_PTR() macro. Callers therefore need to check for errors using the IS_ERR() macro. This change allows drivers to handle contiguous DMA allocation failures gracefully. Signed-off-by: Thierry Reding Acked-by: Sascha Hauer --- drivers/gpu/drm/drm_fb_cma_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_fb_cma_helper.c b/drivers/gpu/drm/drm_fb_cma_helper.c index d6c80a3..fd9d0af 100644 --- a/drivers/gpu/drm/drm_fb_cma_helper.c +++ b/drivers/gpu/drm/drm_fb_cma_helper.c @@ -220,7 +220,7 @@ static int drm_fbdev_cma_create(struct drm_fb_helper *helper, size = mode_cmd.pitches[0] * mode_cmd.height; obj = drm_gem_cma_create(dev, size); - if (!obj) + if (IS_ERR(obj)) return -ENOMEM; fbi = framebuffer_alloc(0, dev->dev);