From patchwork Sat Jun 23 00:41:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Subash Patel X-Patchwork-Id: 9587 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 C5BEF23EE2 for ; Sat, 23 Jun 2012 00:41:36 +0000 (UTC) Received: from mail-gg0-f180.google.com (mail-gg0-f180.google.com [209.85.161.180]) by fiordland.canonical.com (Postfix) with ESMTP id 776CFA18394 for ; Sat, 23 Jun 2012 00:41:36 +0000 (UTC) Received: by ggnf1 with SMTP id f1so2173782ggn.11 for ; Fri, 22 Jun 2012 17:41:36 -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=xQINNCHKHsZm3vtWGhFXXjOwyTVnS0nq6ERol2QqTHM=; b=R7gEw2vpUi2jqu7YwEVtBQ0uayzOFhzTMtEZbAG1xfQrZOhktbzXCQcIpfzXojLXby yVVbmcCp3GgkarJF5jHQHKthUHdb+Cklluna6C42enQkUExcPupgBiZoQbVsCI/WbtLW PMOoWEUV+hOC4MfZiqVGyeO4d9b06oJpeK0PeI3pA8qlaEs02fLYXh1THcd6ayRjuoQp dW21qdt2KG6Fy6Fj9hlkjGse7ZjpqEf4fWqXOMq9QY34zGu2F9SXy0cwhroy+52gx6Yl 7Il7DkkaWfnYggQeNEpeMJQMbzaIscfn3oefBBcXoQ4Y1ZwOdn3KMW9yuCUDlr6RYd3y demw== Received: by 10.50.87.227 with SMTP id bb3mr3158561igb.57.1340412095672; Fri, 22 Jun 2012 17:41:35 -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 v20csp91000ibb; Fri, 22 Jun 2012 17:41:34 -0700 (PDT) Received: by 10.204.136.197 with SMTP id s5mr1527343bkt.21.1340412094162; Fri, 22 Jun 2012 17:41:34 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id iu20si6508850bkc.14.2012.06.22.17.41.31; Fri, 22 Jun 2012 17:41:34 -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 1SiEPo-0000by-Qc; Sat, 23 Jun 2012 00:41:28 +0000 Received: from mail-pb0-f42.google.com ([209.85.160.42]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SiEPn-0000bs-In for linaro-mm-sig@lists.linaro.org; Sat, 23 Jun 2012 00:41:27 +0000 Received: by pbbrp12 with SMTP id rp12so7170099pbb.1 for ; Fri, 22 Jun 2012 17:41:26 -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=Nnf2aNc1xMJ281+Haj8y6v+p21c+M+gZB3yiY6PGQ68=; b=dEhRP1CNvxxgk8GGCDTQvNLV+51bAWdlNGPOfxhGJCgk09tPCnk8ra0sqhyw9tcBJC 1tu9ovj897z97rJOxrIEQuvsABeXQU9g89iChM0sziflZpNWamVbkVSv1JRa2Rvla1u7 CwYzWoAnq5GFo2Z3BQ2D0uJ/57uqFf6T7O2f45jZKZvtkd4XUDXWkfon8l7v/lCb+8/X 5jWIzxhF9ftyLXTm5lPz4+gsUhPcIL4zQCJq6JGHqzg839xwalL8bZWlBfW9E7uPkkkl j+FfFugy5Erh7PmwMUvnN2EI/dS/3e62dmqg2Wvlq+YwIAXHuJFikt6lEN50ojQhixp9 YXNg== Received: by 10.68.225.6 with SMTP id rg6mr15543169pbc.100.1340412086486; Fri, 22 Jun 2012 17:41:26 -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 iv8sm646179pbc.53.2012.06.22.17.41.25 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 22 Jun 2012 17:41:25 -0700 (PDT) From: Subash Patel To: dri-devel@lists.freedesktop.org Date: Fri, 22 Jun 2012 17:41:00 -0700 Message-Id: <1340412060-22929-1-git-send-email-subash.ramaswamy@linaro.org> X-Mailer: git-send-email 1.7.4.1 Cc: linaro-mm-sig@lists.linaro.org, Subash Patel , inki.dae@samsung.com, subash.ramaswamy@linaro.org, airlied@redhat.com, olofj@chromium.org 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: ALoCoQlgM2ArqQLhpNYijNmZfDSDjJn5KipW0eyJzLYj8aQST10E0JTRhHezxOAzsX9zat18AlIn 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. BUG=chrome-os-partner:9481 TEST=built, ran on snow and tried chromeos-install without a crash Change-Id: I0abda74beaedae002a17de9962d7a462a2a7c2fb Signed-off-by: Subash Patel --- 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; }