From patchwork Sat Jun 23 01:12:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Subash Patel X-Patchwork-Id: 9588 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 AAADC23E37 for ; Sat, 23 Jun 2012 01:13:24 +0000 (UTC) Received: from mail-ob0-f180.google.com (mail-ob0-f180.google.com [209.85.214.180]) by fiordland.canonical.com (Postfix) with ESMTP id 4A22AA18923 for ; Sat, 23 Jun 2012 01:13:24 +0000 (UTC) Received: by obbuo19 with SMTP id uo19so2974688obb.11 for ; Fri, 22 Jun 2012 18:13:23 -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: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=NxYsLReHY0twS49HJYPos43oH8J2aRB5CaKjoxDJ3/U=; b=RNe8/cPUeVJ0PjjIZqu2Pn5IfIJ1CyVSmLlaSVXeS0Z9sD1EG/S/KfAXaT2UDa2Y/S jG2KO+ibgmLN3BwiznvY4ugBEHtD8nXSP4YZPfubL6YKwd6oLwVCv6oQe00lqUp+nDPo ABExW8Qi3cqi5EcFgGKouGeFDzQxF0+VLkBl4pSfLRV2fvVxRCEwJ79+Nva+VggOEXqp GUjd7DO4iJRqbXunFh/AOSD5+RNdWM/zEnEddWLTXbnt9HVbu5VqV6zv2ZQMF3vToA5H lUfboeadjKAhWg1awoj4TEpfKTK1WNZZtGKkFFz/VfxQ8imCfyDYfO1JNn50d4uSFiUM TuUQ== Received: by 10.50.40.193 with SMTP id z1mr3298610igk.0.1340414003245; Fri, 22 Jun 2012 18:13:23 -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 v20csp91685ibb; Fri, 22 Jun 2012 18:13:22 -0700 (PDT) Received: by 10.205.137.17 with SMTP id im17mr1512371bkc.9.1340414001457; Fri, 22 Jun 2012 18:13:21 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id ge18si6486877bkc.122.2012.06.22.18.13.19; Fri, 22 Jun 2012 18:13:21 -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 1SiEub-0004uN-5l; Sat, 23 Jun 2012 01:13:17 +0000 Received: from mail-pb0-f42.google.com ([209.85.160.42]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SiEua-0004uI-6Y for linaro-mm-sig@lists.linaro.org; Sat, 23 Jun 2012 01:13:16 +0000 Received: by pbbrp12 with SMTP id rp12so7201814pbb.1 for ; Fri, 22 Jun 2012 18:13:15 -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; bh=HoS9Yk7S7V16KApVM+zdUim/nzzNc7vHCB2oxlD6Qs4=; b=ZWE2HbTARo30Egu2Gq4yQahRoSaytJQicNTSsnBJWVo5hunLbr6nK/wX07gOzjZqfn vqg7bFAjU5AaD5ky5v3GubyHna4Hw63Z9Lp7xLIdFKXDuvzd6ZETwcknu6K3BAhKIFLr y7lnUVVER3lmUNcYbLtK0JRgErDUjB9VRjTiXE88I0adIQlX7b2M+fb174vYnnNhFxFg wZu2j6Si3rBlp/z/rKBhyxICVSaK6C8r0bVm+3gWbvsDSX0s4RZw27DVFdRck6WjusZg LccS8kGFtE36Ivb3gKsiTH1OkFZDi8l0Yr6ShgbDb82XBHH3yseg7TKFusRlhWX1EWeP clyg== Received: by 10.68.218.103 with SMTP id pf7mr16008077pbc.67.1340413994422; Fri, 22 Jun 2012 18:13:14 -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 rd7sm711489pbc.70.2012.06.22.18.13.13 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 22 Jun 2012 18:13:13 -0700 (PDT) From: Subash Patel To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linaro-mm-sig@lists.linaro.org Date: Fri, 22 Jun 2012 18:12:38 -0700 Message-Id: <1340413958-23125-1-git-send-email-subash.ramaswamy@linaro.org> X-Mailer: git-send-email 1.7.4.1 Cc: inki.dae@samsung.com, airlied@redhat.com, olofj@chromium.org, Subash Patel , Subash Patel Subject: [Linaro-mm-sig] [PATCH] 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: ALoCoQnuoM2V3PQ2HH3yJuo+jE2S+hFUx1iVfxi7DDMz8Lp543MBqhEv9yNrw/H9oes0Lfe+U1Tr 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. 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c b/drivers/gpu/drm/exynos/exynos_drm_dmabuf.c index 97325c1..c908a29 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", @@ -241,7 +245,7 @@ struct drm_gem_object *exynos_dmabuf_prime_import(struct drm_device *drm_dev, sgt = dma_buf_map_attachment(attach, DMA_BIDIRECTIONAL); - if (IS_ERR(sgt)) { + if (IS_ERR_OR_NULL(sgt)) { ret = PTR_ERR(sgt); goto err_buf_detach; }