From patchwork Wed Jun 26 01:21:40 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: 2781611 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 231949F968 for ; Wed, 26 Jun 2013 01:22:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 409752023A for ; Wed, 26 Jun 2013 01:22:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 3EC202021B for ; Wed, 26 Jun 2013 01:22:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2B675E62C6 for ; Tue, 25 Jun 2013 18:22:38 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by gabe.freedesktop.org (Postfix) with ESMTP id C5F91E62B5 for ; Tue, 25 Jun 2013 18:21:36 -0700 (PDT) Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MOZ00DBQ7RKEV50@mailout2.samsung.com> for dri-devel@lists.freedesktop.org; Wed, 26 Jun 2013 10:21:34 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.115]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 77.A2.08825.E124AC15; Wed, 26 Jun 2013 10:21:34 +0900 (KST) X-AuditID: cbfee68e-b7f276d000002279-38-51ca421e6dcf Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id A3.87.28381.E124AC15; Wed, 26 Jun 2013 10:21:34 +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 <0MOZ006XH7RWAX00@mmp1.samsung.com>; Wed, 26 Jun 2013 10:21:33 +0900 (KST) From: Seung-Woo Kim To: dri-devel@lists.freedesktop.org, airlied@linux.ie Subject: [PATCH 1/3] drm/prime: fix to put an exported dma_buf for adding handle failure Date: Wed, 26 Jun 2013 10:21:40 +0900 Message-id: <1372209702-25252-2-git-send-email-sw0312.kim@samsung.com> X-Mailer: git-send-email 1.7.4.1 In-reply-to: <1372209702-25252-1-git-send-email-sw0312.kim@samsung.com> References: <1372209702-25252-1-git-send-email-sw0312.kim@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRmVeSWpSXmKPExsWyRsSkWFfO6VSgwbHLQha9504yWVz5+p7N 4mzTG3aLGZNfslns3TmZ0YHVY/u3B6we97uPM3n0bVnFGMAcxWWTkpqTWZZapG+XwJVx9ft0 poI7XBVNk4QbGFs4uxg5OSQETCS2/elhgrDFJC7cW8/WxcjFISSwlFFi9pfPrDBFPzZeZoVI LGKUmLR9OVRVM5NE46ltYFVsAjoS+5f8BrNFBEwlzl6+xgxiMwt4S+zYfg8sLiwQJTHzwQ+g dRwcLAKqEt135UHCvAJuEu8O/2aDWKYgseDeWzCbU8Bd4tHbZYwgthBQTfvy9+wQNb/ZJLrv aYHYLAICEt8mH2IBGSkhICux6QAzRImkxMEVN1gmMAovYGRYxSiaWpBcUJyUXmSkV5yYW1ya l66XnJ+7iREYvKf/PevbwXjzgPUhxmSgcROZpUST84HBn1cSb2hsZmRhamJqbGRuaUaasJI4 r1qLdaCQQHpiSWp2ampBalF8UWlOavEhRiYOTqkGRrMLb+ac8xJRWf8nc4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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.5 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 When drm_prime_add_buf_handle() returns failure for an exported dma_buf, the dma_buf was already allocated and its refcount was increased, so it needs to be put. Signed-off-by: YoungJun Cho Signed-off-by: Seung-Woo Kim Signed-off-by: Kyungmin Park --- drivers/gpu/drm/drm_prime.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 5b7b911..afff7c8 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -235,7 +235,7 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev, ret = drm_prime_add_buf_handle(&file_priv->prime, obj->export_dma_buf, handle); if (ret) - goto out; + goto fail_put_dmabuf; *prime_fd = dma_buf_fd(buf, flags); mutex_unlock(&file_priv->prime.lock); @@ -244,6 +244,12 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev, out_have_obj: get_dma_buf(dmabuf); *prime_fd = dma_buf_fd(dmabuf, flags); + goto out; + +fail_put_dmabuf: + /* clear NOT to be checked when releasing dma_buf */ + obj->export_dma_buf = NULL; + dma_buf_put(buf); out: drm_gem_object_unreference_unlocked(obj); mutex_unlock(&file_priv->prime.lock);