From patchwork Mon Jun 25 18:22:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Subash Patel X-Patchwork-Id: 9612 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DCB4523E4F for ; Mon, 25 Jun 2012 18:23:54 +0000 (UTC) Received: from mail-gh0-f180.google.com (mail-gh0-f180.google.com [209.85.160.180]) by fiordland.canonical.com (Postfix) with ESMTP id 95C7CA18804 for ; Mon, 25 Jun 2012 18:23:54 +0000 (UTC) Received: by ghbz12 with SMTP id z12so3382255ghb.11 for ; Mon, 25 Jun 2012 11:23:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :dkim-signature:from:to:date:message-id:x-mailer:in-reply-to :references:cc:subject:x-beenthere:x-mailman-version:precedence :list-id:list-unsubscribe:list-archive:list-post:list-help :list-subscribe:mime-version:content-type:content-transfer-encoding :sender:errors-to:x-gm-message-state; bh=bioUBmR2CxF0N+OayMn0TUcyZ4K5ZwaPLIAZKfsEgjs=; b=CFU/keQY03ICKvCFM2YBSeo/Ue6YM9CXK6IIZVhX5ExdOnzRh+oH+s4ObGr6BwPRki UN4YEPGA2U2MmurhVMFwTGT2tIX7bydnIitJV4u4d8NKSFcoHwqhptTmblPa3CytSiqU JSbMnE52wxOfSkzkx7ILkUHNHREA7xN15SCnAF3QZlZPKEydyv/SdIJUT7Yh9mB1msOa PZIO5yZ7SIEIKgnQIIZh5OlcSePJEMw/5Qqr/5WWfsogN23IhOC4aZQPPSEveavFliRY V76G8c6kH92C566+qYgjQo7Hamoae3YNBpptV+krMGt7xrn+g5rt7Obt6lvyuYMCMjYr TnPA== Received: by 10.50.46.232 with SMTP id y8mr8876395igm.57.1340648633578; Mon, 25 Jun 2012 11:23:53 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp56540ibb; Mon, 25 Jun 2012 11:23:52 -0700 (PDT) Received: by 10.180.80.37 with SMTP id o5mr26427438wix.12.1340648632217; Mon, 25 Jun 2012 11:23:52 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id cp6si12888312wib.45.2012.06.25.11.23.50; Mon, 25 Jun 2012 11:23:52 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org; dkim=neutral (body hash did not verify) header.i=@gmail.com Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SjDwz-000582-PS; Mon, 25 Jun 2012 18:23:49 +0000 Received: from mail-pb0-f42.google.com ([209.85.160.42]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SjDwy-00055y-9g for linaro-mm-sig@lists.linaro.org; Mon, 25 Jun 2012 18:23:48 +0000 Received: by mail-pb0-f42.google.com with SMTP id rp12so11608709pbb.1 for ; Mon, 25 Jun 2012 11:23:47 -0700 (PDT) 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=pRQLW+jkFzGlLLehNCMoQG/MobAO4lMPflXZ32SoTM8=; b=ZZLyf5UEiCyD+xlHjmVZBtoNH55vitVpFgyefgUBgE6+jXBK7s5EVRGZvn/Uw4jRvx W2GFKhNDy4SJPx9Xz92Gg7VmOs0oPmxT3kDtuP6sqaDGKxahSPdrL8pExSMEfUXeydzu CFP7XEUlmIqfMlLFzRIHSYpU7OjYVx4JWchBjwQbf+F+oM1U+Q0ADTWgzxaawtVJpGOG 5YYTonUahzbjY6LF5yOY+a3myp6SNaQ2yyvxAkim6d2uUIXQwkMQWolPyaTFBa+LGKNo 6tiUavNRs2KBvQRzCCH5ogkUhqUVRNRMMxYAN9qJF5aB4OYaPA67MmholgGTi2NcTAYK 8sQA== Received: by 10.68.200.101 with SMTP id jr5mr26968807pbc.153.1340648627672; Mon, 25 Jun 2012 11:23:47 -0700 (PDT) Received: from localhost.localdomain (dhcp-172-22-52-171.mtv.corp.google.com [172.22.52.171]) by mx.google.com with ESMTPS id oc5sm5539749pbb.54.2012.06.25.11.23.46 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 25 Jun 2012 11:23:47 -0700 (PDT) From: Subash Patel To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linaro-mm-sig@lists.linaro.org Date: Mon, 25 Jun 2012 11:22:56 -0700 Message-Id: <1340648577-28402-2-git-send-email-subash.ramaswamy@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1340648577-28402-1-git-send-email-subash.ramaswamy@linaro.org> References: <1340648577-28402-1-git-send-email-subash.ramaswamy@linaro.org> Cc: inki.dae@samsung.com, airlied@redhat.com, olofj@chromium.org, Subash Patel , Subash Patel Subject: [Linaro-mm-sig] [PATCH 1/2] DRM: Exynos: return NULL if exynos_pages_to_sg fails X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQnzddu+qXKfNVcr+zbXkoydb9Oy9Po3J/NXLPxNfp0oOg2Dm2wkYumNcE70ft//FlpmhsNA From: Subash Patel exynos_pages_to_sg() internally calls sg_kmalloc() which can return no pages when the system is under high memory crunch. One such instance is chromeos-install in the chromeos. This patch adds check for the return value of the function in subject to return NULL on failure. Change-Id: I541ed30491a926ebe72738225041c9f2d88007bc Signed-off-by: Subash Patel CC: dri-devel@lists.freedesktop.org CC: linux-samsung-soc@vger.kernel.org CC: linaro-mm-sig@lists.linaro.org CC: inki.dae@samsung.com CC: airlied@redhat.com CC: olofj@chromium.org --- drivers/gpu/drm/exynos/exynos_drm_dmabuf.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c index 97325c1..52cf761 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c @@ -87,6 +87,10 @@ static struct sg_table * npages = buf->size / buf->page_size; sgt = exynos_pages_to_sg(buf->pages, npages, buf->page_size); + if (!sgt) { + DRM_DEBUG_PRIME("exynos_pages_to_sg returned NULL!\n"); + goto err_unlock; + } nents = dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir); DRM_DEBUG_PRIME("npages = %d buffer size = 0x%lx page_size = 0x%lx\n",