From patchwork Mon Jun 24 06:34:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seung-Woo Kim X-Patchwork-Id: 2768791 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2843CC0AB1 for ; Mon, 24 Jun 2013 06:34:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 259EB20108 for ; Mon, 24 Jun 2013 06:34:31 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 8A8B02010B for ; Mon, 24 Jun 2013 06:34:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F1484E5CF9 for ; Sun, 23 Jun 2013 23:34:28 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.samsung.com (mailout3.samsung.com [203.254.224.33]) by gabe.freedesktop.org (Postfix) with ESMTP id 6ABC2E5CD5 for ; Sun, 23 Jun 2013 23:34:16 -0700 (PDT) Received: from epcpsbgr5.samsung.com (u145.gpu120.samsung.co.kr [203.254.230.145]) by mailout3.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MOV00CTNWX0Z7P0@mailout3.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 24 Jun 2013 15:34:14 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.115]) by epcpsbgr5.samsung.com (EPCPMTA) with SMTP id F2.81.11618.668E7C15; Mon, 24 Jun 2013 15:34:14 +0900 (KST) X-AuditID: cbfee691-b7fef6d000002d62-6d-51c7e866dbb8 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 34.6B.21068.668E7C15; Mon, 24 Jun 2013 15:34:14 +0900 (KST) Received: from localhost.localdomain ([10.90.8.56]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MOV00JYSWX0LR70@mmp1.samsung.com>; Mon, 24 Jun 2013 15:34:13 +0900 (KST) From: Seung-Woo Kim To: dri-devel@lists.freedesktop.org, airlied@linux.ie Subject: [PATCH] drm/prime: fix to check return of dma_map_sg in prime helper Date: Mon, 24 Jun 2013 15:34:21 +0900 Message-id: <1372055661-22786-1-git-send-email-sw0312.kim@samsung.com> X-Mailer: git-send-email 1.7.4.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrKLMWRmVeSWpSXmKPExsWyRsSkWDftxfFAg+Zlaha9504yWXxY6mJx 5et7NouzTW/YLWZMfslmsXfnZEYHNo/t3x6wetzvPs7k0dv8js2jb8sqxgCWKC6blNSczLLU In27BK6MpfOushV85Kg49uY/YwPjPvYuRk4OCQETibabncwQtpjEhXvr2boYuTiEBJYySizZ 9BauaOvLA8wQiUWMEsuO/4dympkk9rV8YASpYhPQkdi/5DcriC0iYCpx9vI1sLHMAskSBx4s B5skLOArce7OE7B6FgFVifYPq1hAbF4BN4kLD85DnaEgseDeW7AzJATes0ncbWxng2gQkPg2 +RBQAwdQQlZi0wGoekmJgytusExgFFzAyLCKUTS1ILmgOCm9yFSvODG3uDQvXS85P3cTIzBI T/97NnEH4/0D1ocYk4HGTWSWEk3OBwZ5Xkm8obGZkYWpiamxkbmlGWnCSuK86i3WgUIC6Ykl qdmpqQWpRfFFpTmpxYcYmTg4pRoYU2d/Ew0IvBEk4mkmlVZyUoHh3vY5RozlGya0pXEZebgl ajavnugZ5H91Xda6c3GZydGX+a6o1b7888l1923p0Pca8oeuRh343deWw6R5ZzqPTEFpoYTh qQP/dCtjHQRO/Xv0/WbIpYAn3y+tkOsInME49WHjg1L5eM5JzSc7r1WLtu36cCdBiaU4I9FQ i7moOBEA9d1y/mgCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRmVeSWpSXmKPExsVy+t9jAd20F8cDDW5flrXoPXeSyeLDUheL K1/fs1mcbXrDbjFj8ks2i707JzM6sHls//aA1eN+93Emj97md2wefVtWMQawRDUw2mSkJqak Fimk5iXnp2TmpdsqeQfHO8ebmhkY6hpaWpgrKeQl5qbaKrn4BOi6ZeYAbVdSKEvMKQUKBSQW Fyvp22GaEBripmsB0xih6xsSBNdjZIAGEtYwZiydd5Wt4CNHxbE3/xkbGPexdzFyckgImEhs fXmAGcIWk7hwbz1bFyMXh5DAIkaJZcf/M0M4zUwS+1o+MIJUsQnoSOxf8psVxBYRMJU4e/ka WDezQLLEgQfLwaYKC/hKnLvzBKyeRUBVov3DKhYQm1fATeLCg/NQ2xQkFtx7yzaBkXsBI8Mq RtHUguSC4qT0XCO94sTc4tK8dL3k/NxNjOAYeCa9g3FVg8UhRgEORiUe3gXmxwOFWBPLiitz DzFKcDArifAeugIU4k1JrKxKLcqPLyrNSS0+xJgMtH0is5Rocj4wPvNK4g2NTcyMLI3MDS2M jM1JE1YS5z3Yah0oJJCeWJKanZpakFoEs4WJg1OqgZHjxtuQ6W2LyspPTn/JpznjOofQviNl Dt/ZUourCiumHJEPnSV2NqPV8JRmqGq11bWX9fXnM0srJd3kH8svMFyt9zj3vrz+fJ2Pm6R7 X280tN9nGTzjYx7DwwP+UQsPy79b9+WESovjhcPPH6X0sRvI+Uj2h36YPUeuzYjd6vAJhiRX /4Rrs5VYijMSDbWYi4oTARCsiv3FAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Cc: kyungmin.park@samsung.com, sw0312.kim@samsung.com, yj44.cho@samsung.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 X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: YoungJun Cho The dma_map_sg(), in map_dma_buf callback operation of prime helper, can return 0 when it fails to map, so it needs to release related resources. Signed-off-by: YoungJun Cho Signed-off-by: Seung-Woo Kim Signed-off-by: Kyungmin Park --- drivers/gpu/drm/drm_prime.c | 9 +++++++-- 1 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 5b7b911..f1699e9 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -74,8 +74,13 @@ static struct sg_table *drm_gem_map_dma_buf(struct dma_buf_attachment *attach, sgt = obj->dev->driver->gem_prime_get_sg_table(obj); - if (!IS_ERR_OR_NULL(sgt)) - dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir); + if (!IS_ERR_OR_NULL(sgt)) { + if (!dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir)) { + sg_free_table(sgt); + kfree(sgt); + sgt = ERR_PTR(-ENOMEM); + } + } mutex_unlock(&obj->dev->struct_mutex); return sgt;