From patchwork Wed Sep 11 14:09:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 2877441 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 BA2C1BF43F for ; Thu, 12 Sep 2013 10:08:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8C9DD201EA for ; Thu, 12 Sep 2013 10:08:09 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2EBCF201C7 for ; Thu, 12 Sep 2013 10:08:08 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1B8A8E63F6 for ; Thu, 12 Sep 2013 03:08:08 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bk0-f50.google.com (mail-bk0-f50.google.com [209.85.214.50]) by gabe.freedesktop.org (Postfix) with ESMTP id 4BA8BE6351 for ; Wed, 11 Sep 2013 07:09:04 -0700 (PDT) Received: by mail-bk0-f50.google.com with SMTP id mz11so3551663bkb.23 for ; Wed, 11 Sep 2013 07:09:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type; bh=aJMEaGGpDNtfmd7anSIHmeAHnDv45oCdfSIGBf2SMPo=; b=d75oKbSP/EhBnnCVvc2f8JDW7dPuZPYnSQQNVrFTdbEuPZb+wZCw9nNoInShQdjrFM Snzj08eMWjf23TeA+Al05+ro2lW2Dd2F8GqnMwADyICLctD2iKS2AqhH+9dXhyPihxoB W382R3XDC0PKnUZjQZ6qtcfZmq5TF6XbQ78vxTj6bTtwONwdAMJ1AZZk1sSM3fohPfG0 e5WE52Hrq+RHWH0DM83GnUcxZYrnDf842gi/UyFOMIREN8wG8FVW2D162y/lB3cWSgwu tCgc88uMBi/YzfAYo+JgydhY8Mnm/TU7ZI8f8ePwrlObeUOaJ/9iyCGVAg14SYg3eCVX +/gA== MIME-Version: 1.0 X-Received: by 10.204.167.140 with SMTP id q12mr1665055bky.2.1378908542938; Wed, 11 Sep 2013 07:09:02 -0700 (PDT) Received: by 10.205.13.74 with HTTP; Wed, 11 Sep 2013 07:09:02 -0700 (PDT) Date: Wed, 11 Sep 2013 22:09:02 +0800 Message-ID: Subject: [PATCH] drm/msm: fix potential NULL pointer dereference From: Wei Yongjun To: airlied@linux.ie, robdclark@gmail.com X-Mailman-Approved-At: Thu, 12 Sep 2013 02:59:26 -0700 Cc: yongjun_wei@trendmicro.com.cn, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org 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: , 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.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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: Wei Yongjun The dereference to 'pdata' should be moved below the NULL test. Signed-off-by: Wei Yongjun --- drivers/gpu/drm/msm/msm_gpu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index e1e1ec9..6b50e6b 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -29,13 +29,14 @@ static void bs_init(struct msm_gpu *gpu, struct platform_device *pdev) { struct drm_device *dev = gpu->dev; - struct kgsl_device_platform_data *pdata = pdev->dev.platform_data; + struct kgsl_device_platform_data *pdata; if (!pdev) { dev_err(dev->dev, "could not find dtv pdata\n"); return; } + pdata = pdev->dev.platform_data; if (pdata->bus_scale_table) { gpu->bsc = msm_bus_scale_register_client(pdata->bus_scale_table); DBG("bus scale client: %08x", gpu->bsc);