From patchwork Fri Nov 7 11:44:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Inki Dae X-Patchwork-Id: 5251561 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 0AA8FC11AC for ; Fri, 7 Nov 2014 11:44:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 38DC820145 for ; Fri, 7 Nov 2014 11:44:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 542A92012E for ; Fri, 7 Nov 2014 11:44:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751579AbaKGLoK (ORCPT ); Fri, 7 Nov 2014 06:44:10 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:58378 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751317AbaKGLoI (ORCPT ); Fri, 7 Nov 2014 06:44:08 -0500 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 <0NEO0005G39IRXD0@mailout4.samsung.com> for linux-samsung-soc@vger.kernel.org; Fri, 07 Nov 2014 20:44:06 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.115]) by epcpsbgr3.samsung.com (EPCPMTA) with SMTP id 26.B7.18484.680BC545; Fri, 07 Nov 2014 20:44:06 +0900 (KST) X-AuditID: cbfee68f-f791c6d000004834-4e-545cb086fc02 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 67.D9.09430.680BC545; Fri, 07 Nov 2014 20:44:06 +0900 (KST) Received: from daeinki-desktop.10.32.193.11 ([10.252.83.67]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NEO00H0739IWME0@mmp1.samsung.com>; Fri, 07 Nov 2014 20:44:06 +0900 (KST) From: Inki Dae To: airlied@linux.ie, dri-devel@lists.freedesktop.org Cc: linux-samsung-soc@vger.kernel.org, Inki Dae Subject: [PATCH] drm/exynos: g2d: fix null pointer dereference Date: Fri, 07 Nov 2014 20:44:05 +0900 Message-id: <1415360645-29246-1-git-send-email-inki.dae@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHLMWRmVeSWpSXmKPExsWyRsSkWLdtQ0yIwZ3Ziha9504yWVz5+p7N YtL9CSwWM87vY3Jg8dj+7QGrx/3u40wefVtWMXp83iQXwBLFZZOSmpNZllqkb5fAldHWv5Kx oJu7ouX4ItYGxp2cXYycHBICJhL/1/ewQthiEhfurWfrYuTiEBJYyihx+9ldZpiij/uXsEIk FjFK/O+7yw7hdDNJ3Px/jg2kik1AVWLiivtgtoiAqUTHpKUsIDazgJvE4tPLgWwODmEBO4l9 W5xBwixA5cen3WYCsXkFXCS2TH3ODlIiIaAgMWeSDch4CYHHbBIbTy1lg6gXkPg2+RALRI2s xKYDULdJShxccYNlAqPgAkaGVYyiqQXJBcVJ6UXGesWJucWleel6yfm5mxiBwXj637P+HYx3 D1gfYhTgYFTi4b3BGxMixJpYVlyZe4jRFGjDRGYp0eR8YMjnlcQbGpsZWZiamBobmVuaKYnz LpT6GSwkkJ5YkpqdmlqQWhRfVJqTWnyIkYmDU6qBsXTt28QnjfckWWq6lkufYohh6ZSM+HCo nV3ou8vyqxPjEs/nMZ+f3df3ff6n4zGmtsdN6r3ffoy5zzJdV/T6hY2yk/+XzNWdtvhzyA8J 3jLD3TpxRkGSn6ouxajI2h1c+kjqoKtb3j5Fl4LUFx8+xu40OfL61qTKjeI6t7NPnmjauP7Q pd6Yy0osxRmJhlrMRcWJAGejWCdBAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRmVeSWpSXmKPExsVy+t9jAd22DTEhBsueSVr0njvJZHHl63s2 i0n3J7BYzDi/j8mBxWP7twesHve7jzN59G1ZxejxeZNcAEtUA6NNRmpiSmqRQmpecn5KZl66 rZJ3cLxzvKmZgaGuoaWFuZJCXmJuqq2Si0+ArltmDtBOJYWyxJxSoFBAYnGxkr4dpgmhIW66 FjCNEbq+IUFwPUYGaCBhDWNGW/9KxoJu7oqW44tYGxh3cnYxcnJICJhIfNy/hBXCFpO4cG89 WxcjF4eQwCJGif99d9khnG4miZv/z7GBVLEJqEpMXHEfzBYRMJXomLSUBcRmFnCTWHx6OZDN wSEsYCexb4szSJgFqPz4tNtMIDavgIvElqnP2UFKJAQUJOZMspnAyL2AkWEVo2hqQXJBcVJ6 rpFecWJucWleul5yfu4mRnCoP5PewbiqweIQowAHoxIP7w3emBAh1sSy4srcQ4wSHMxKIryz VwOFeFMSK6tSi/Lji0pzUosPMZoCLZ/ILCWanA+Mw7ySeENjEzMjSyNzQwsjY3Mlcd6DrdaB QgLpiSWp2ampBalFMH1MHJxSDYwZIdPPX6yv1S1Mc1g3Mf3Xl33JWvPXXfDfrfSz/2BbsPXN OTz55v+uXr758Mnn086C4g+Z7pjYtokpV/Y9vNVobe7ccXl73YlQ3TtBEfvmauy/dSDt6DEN 202imfJZpe1FKSKtv/iOLLzeFJWo3Nujq/BngbSDifOzXf8v3mX+uHHbO+7Pp/cosRRnJBpq MRcVJwIA7rLMsIsCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 This patch fixes a null pointer dereference issue incurred by calling g2d_remove when exynos_drm_platform_probe is failed. cmdlist_pool of g2d is allocated when g2d sub driver is probed. So if exynos_drm_platform_probe is failed, the g2d sub driver is not probed and the cmdlist_pool is still NULL. This patch makes for g2d_remove function tries to free the cmdlist_poll only in case that the cmdlist_poll is allocated. Signed-off-by: Inki Dae --- drivers/gpu/drm/exynos/exynos_drm_g2d.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_g2d.c b/drivers/gpu/drm/exynos/exynos_drm_g2d.c index df7a77d..6ff8599 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_g2d.c +++ b/drivers/gpu/drm/exynos/exynos_drm_g2d.c @@ -302,9 +302,12 @@ static void g2d_fini_cmdlist(struct g2d_data *g2d) struct exynos_drm_subdrv *subdrv = &g2d->subdrv; kfree(g2d->cmdlist_node); - dma_free_attrs(subdrv->drm_dev->dev, G2D_CMDLIST_POOL_SIZE, - g2d->cmdlist_pool_virt, - g2d->cmdlist_pool, &g2d->cmdlist_dma_attrs); + + if (g2d->cmdlist_pool_virt && g2d->cmdlist_pool) { + dma_free_attrs(subdrv->drm_dev->dev, G2D_CMDLIST_POOL_SIZE, + g2d->cmdlist_pool_virt, + g2d->cmdlist_pool, &g2d->cmdlist_dma_attrs); + } } static struct g2d_cmdlist_node *g2d_get_cmdlist(struct g2d_data *g2d)