From patchwork Thu Jul 4 07:21:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonyoung Shim X-Patchwork-Id: 2822261 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 963C6BF4A1 for ; Thu, 4 Jul 2013 07:23:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A3CC020141 for ; Thu, 4 Jul 2013 07:23:32 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id D0DA720140 for ; Thu, 4 Jul 2013 07:23:31 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C1D51E6658 for ; Thu, 4 Jul 2013 00:23:31 -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 A83C1E6269 for ; Thu, 4 Jul 2013 00:21:27 -0700 (PDT) Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MPE009I2HQZ37F0@mailout2.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 04 Jul 2013 16:21:26 +0900 (KST) Received: from epcpsbgm1.samsung.com ( [172.20.52.116]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 92.62.03969.67225D15; Thu, 04 Jul 2013 16:21:26 +0900 (KST) X-AuditID: cbfee68f-b7f436d000000f81-12-51d522767700 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 75.36.28381.67225D15; Thu, 04 Jul 2013 16:21:26 +0900 (KST) Received: from localhost.localdomain ([10.89.53.198]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MPE006Y8HRPTSA0@mmp2.samsung.com>; Thu, 04 Jul 2013 16:21:26 +0900 (KST) From: Joonyoung Shim To: dri-devel@lists.freedesktop.org Subject: [PATCH RESEND] drm/prime: fix sgt NULL checking Date: Thu, 04 Jul 2013 16:21:33 +0900 Message-id: <1372922493-25859-1-git-send-email-jy0922.shim@samsung.com> X-Mailer: git-send-email 1.8.1.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBLMWRmVeSWpSXmKPExsWyRsSkRLdM6WqgwaHHAhYnri9isrjy9T2b A5PHzll32T3udx9nCmCK4rJJSc3JLEst0rdL4Mp4+/slU0Ebe8WHQycYGxhfs3YxcnJICJhI TH26kRHCFpO4cG89WxcjF4eQwFJGifYJr9lgiq6cPs8IkZjOKLHx8D0op5VJYkn3HLAqNgE9 iTvbjjOB2CICyhJ/J64CG8ssICrxZXcTO4gtLGAhMa9lD5jNIqAqcWrhe7AaXgF3iXO3rkJt U5D4efkE2BkSAifYJE5cm8wG0SAg8W3yIZYuRg6ghKzEpgPMEPWSEgdX3GCZwCi4gJFhFaNo akFyQXFSepGxXnFibnFpXrpecn7uJkZgqJ3+96x/B+PdA9aHGJOBxk1klhJNzgeGal5JvKGx mZGFqYmpsZG5pRlpwkrivGot1oFCAumJJanZqakFqUXxRaU5qcWHGJk4OKUaGM3YCjxm62y5 7MnjVO65hu3IvY9Hmnes1hS/uj4kdVex0cp7lw68sa/ik6xa+aihm9Vd49RDiTMMNvv1RVbd y+NacVRF37f+8Z1Oj3dBN99uCFQ2PX16U+pkxnUni/y23tr9wmHVIqVF57/LhKnLZEdfa1nz fId/JfPDvd9OWnN7fVVy377zjI8SS3FGoqEWc1FxIgDSrnBWSwIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprKIsWRmVeSWpSXmKPExsVy+t9jQd0ypauBBo9/cVqcuL6IyeLK1/ds DkweO2fdZfe4332cKYApqoHRJiM1MSW1SCE1Lzk/JTMv3VbJOzjeOd7UzMBQ19DSwlxJIS8x N9VWycUnQNctMwdogZJCWWJOKVAoILG4WEnfDtOE0BA3XQuYxghd35AguB4jAzSQsIYx4+3v l0wFbewVHw6dYGxgfM3axcjJISFgInHl9HlGCFtM4sK99WxdjFwcQgLTGSU2Hr7HCOG0Mkks 6Z7DBlLFJqAncWfbcSYQW0RAWeLvxFVg3cwCohJfdjexg9jCAhYS81r2gNksAqoSpxa+B6vh FXCXOHfrKhvENgWJn5dPsE1g5F7AyLCKUTS1ILmgOCk911CvODG3uDQvXS85P3cTIziQn0nt YFzZYHGIUYCDUYmHV8LqSqAQa2JZcWXuIUYJDmYlEV4njquBQrwpiZVVqUX58UWlOanFhxiT gbZPZJYSTc4HRlleSbyhsYmZkaWRuaGFkbE5acJK4rwHWq0DhQTSE0tSs1NTC1KLYLYwcXBK NTCWuHFubv6Yfn/l9V8zC1tUyw5PUfpqcrV9/SVe7Uon3SqupmtGzbtyou93cPfxGWy5zBN0 8cy+s64vr3KJPTR+bMHJF77c91Fn+O5TLS8+ZmcUODLesd8zd536U3nbBiabyUJx8uLhiRsW hKqfrDiXxXg1S+DAshOn7y9gXcPUqvdK3YbD4YYSS3FGoqEWc1FxIgBIwrV/qAIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected 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=-4.4 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 The drm_gem_map_detach() can be called with sgt is NULL. Signed-off-by: Joonyoung Shim --- drivers/gpu/drm/drm_prime.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c index 1e0de41..ff5fece 100644 --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -119,12 +119,13 @@ static void drm_gem_map_detach(struct dma_buf *dma_buf, return; sgt = prime_attach->sgt; + if (sgt) { + if (prime_attach->dir != DMA_NONE) + dma_unmap_sg(attach->dev, sgt->sgl, sgt->nents, + prime_attach->dir); + sg_free_table(sgt); + } - if (prime_attach->dir != DMA_NONE) - dma_unmap_sg(attach->dev, sgt->sgl, sgt->nents, - prime_attach->dir); - - sg_free_table(sgt); kfree(sgt); kfree(prime_attach); attach->priv = NULL;