From patchwork Thu Jul 4 07:19:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonyoung Shim X-Patchwork-Id: 2822231 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 7C3009F3C3 for ; Thu, 4 Jul 2013 07:21:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 95FFE20143 for ; Thu, 4 Jul 2013 07:21:24 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6127720140 for ; Thu, 4 Jul 2013 07:21:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 45CB9E665F for ; Thu, 4 Jul 2013 00:21:23 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EB1AE665B for ; Thu, 4 Jul 2013 00:19:10 -0700 (PDT) Received: from epcpsbgr3.samsung.com (u143.gpu120.samsung.co.kr [203.254.230.143]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MPE00GRKHN2ACE0@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 04 Jul 2013 16:19:05 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.113]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id B3.61.03969.9E125D15; Thu, 04 Jul 2013 16:19:05 +0900 (KST) X-AuditID: cbfee68f-b7f436d000000f81-4b-51d521e9df0d Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id B8.B0.21068.9E125D15; Thu, 04 Jul 2013 16:19:05 +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 <0MPE0044YHNTZ3J0@mmp2.samsung.com>; Thu, 04 Jul 2013 16:19:05 +0900 (KST) From: Joonyoung Shim To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/prime: fix sgt NULL checking Date: Thu, 04 Jul 2013 16:19:12 +0900 Message-id: <1372922352-25711-1-git-send-email-jy0922.shim@samsung.com> X-Mailer: git-send-email 1.8.1.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGLMWRmVeSWpSXmKPExsWyRsSkUPel4tVAgzuHpS1OXF/EZHHl63s2 ByaPnbPusnvc7z7OFMAUxWWTkpqTWZZapG+XwJUx/9MVloI97BULv5Q0MM5j62Lk5JAQMJE4 8WgnO4QtJnHh3nqgOBeHkMBSRokXK94zwRV9+c4IYgsJTGeU6OthhShqZZKYt+wbWDebgJ7E nW3HwRpEBJQl/k5cBdbALCAq8WV3E1iNsIChxMq2H8wgNouAqsSlP19YQWxeAXeJn0fmQ12h IPHz8gmwKyQEjrBJzJ15kQmiQUDi2+RDLF2MHEAJWYlNB5gh6iUlDq64wTKBUXABI8MqRtHU guSC4qT0ImO94sTc4tK8dL3k/NxNjMAwO/3vWf8OxrsHrA8xJgONm8gsJZqcDwzTvJJ4Q2Mz IwtTE1NjI3NLM9KElcR51VqsA4UE0hNLUrNTUwtSi+KLSnNSiw8xMnFwSjUwHg1/LvbmUMDt ezafSh52ldrOmazi+HmK8zaFt/4Lpr3YyvOkv6tEzbd380XBrzZCUtd9fLJadxTvORFcy6VY aP5nYjlvq5vDlb/drZeT3Rf+Eb26V/LtUmO59Wb7qmavXLW1w75L9dzpHqm0wJB1QoG7w9lu TGs8tpI3Jm3PCftVX+PmXol8rsRSnJFoqMVcVJwIAAXYcQFJAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprMIsWRmVeSWpSXmKPExsVy+t9jQd2XilcDDTZ+ELE4cX0Rk8WVr+/Z HJg8ds66y+5xv/s4UwBTVAOjTUZqYkpqkUJqXnJ+SmZeuq2Sd3C8c7ypmYGhrqGlhbmSQl5i bqqtkotPgK5bZg7QAiWFssScUqBQQGJxsZK+HaYJoSFuuhYwjRG6viFBcD1GBmggYQ1jxvxP V1gK9rBXLPxS0sA4j62LkZNDQsBE4sSX74wQtpjEhXvrweJCAtMZJfp6WLsYuYDsViaJecu+ sYMk2AT0JO5sO84EYosIKEv8nbgKrJlZQFTiy+4msBphAUOJlW0/mEFsFgFViUt/vrCC2LwC 7hI/j8xnh1imIPHz8gm2CYzcCxgZVjGKphYkFxQnpeca6RUn5haX5qXrJefnbmIEB/Ez6R2M qxosDjEKcDAq8fBKWF0JFGJNLCuuzD3EKMHBrCTC68RxNVCINyWxsiq1KD++qDQntfgQYzLQ 9onMUqLJ+cAIyyuJNzQ2MTOyNDI3tDAyNidNWEmc92CrdaCQQHpiSWp2ampBahHMFiYOTqkG xrymyY9Cn31vvvHbU+5I69a9ETsN92l8mfP5kd79inlm7zesTjttky/0dOOc/wenXUgwul2w 6O1TBrUcvwsBq1xtCx9k3yq5ecjdNv5HhpNNapLY13fWB0rVk65cND8pfmfyfm6lYG5jYek4 y9NtL7I2+b4TEPRjU3Gyzm6waL26zjnc/bnaMSWW4oxEQy3mouJEAELffsemAgAA 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. Change-Id: I3b2f5878dfac6e1e77aebeeb7be781113dec59a7 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;