From patchwork Sun Dec 2 13:35:52 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 1831101 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 6F954DF254 for ; Sun, 2 Dec 2012 16:52:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 44839E5DF4 for ; Sun, 2 Dec 2012 08:52:59 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qa0-f42.google.com (mail-qa0-f42.google.com [209.85.216.42]) by gabe.freedesktop.org (Postfix) with ESMTP id 07D9CE5C6E for ; Sun, 2 Dec 2012 05:35:52 -0800 (PST) Received: by mail-qa0-f42.google.com with SMTP id hg5so716483qab.15 for ; Sun, 02 Dec 2012 05:35:52 -0800 (PST) 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=6as0OuISfN+Gt7ExMi8eFByHk7uwuenxwxqBZJB1b20=; b=pGDIcYK4/ThkIi6OWB2/sI2X7Oh2ms98yy6Kcr6/TxhbOzTb6DwsYPIGUmxmjbxT8K arUGUzjrUBn9GbT/J5Jv/1YBcGe2J1rCgCqF+Omz+ZGen1A6pzDh0e96v7MIhxT7a+4O uOPPGAXyRRSa4Ph0F9HHU1i8LmyFrJybeg8qVnfMeilfwNVoRyLaG+U89i9Wvzk0mFOZ 0oIq4I+fM6cuyT8iB3gYHC6xyY+LnrIutlaxIaKBpY1/MDyGc8LgDloP5h+Lw/bd7YyU KTJoZ8fjdxKK0qNThZfOcr4g2NJy3pLT/YXyChjn1df0KMYAQ9RVY8NRBdizuXXiEjMD trqw== MIME-Version: 1.0 Received: by 10.224.59.197 with SMTP id m5mr12711536qah.4.1354455352489; Sun, 02 Dec 2012 05:35:52 -0800 (PST) Received: by 10.229.126.165 with HTTP; Sun, 2 Dec 2012 05:35:52 -0800 (PST) Date: Sun, 2 Dec 2012 08:35:52 -0500 Message-ID: Subject: [PATCH -next] gma500: medfield: fix potential NULL pointer dereference in mdfld_dsi_brightness_init() From: Wei Yongjun To: airlied@linux.ie X-Mailman-Approved-At: Sun, 02 Dec 2012 08:50:12 -0800 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 From: Wei Yongjun The dereference to 'sender' should be moved below the NULL test. Signed-off-by: Wei Yongjun --- drivers/gpu/drm/gma500/mdfld_dsi_output.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_output.c b/drivers/gpu/drm/gma500/mdfld_dsi_output.c index 637dd84..478f8b9 100644 --- a/drivers/gpu/drm/gma500/mdfld_dsi_output.c +++ b/drivers/gpu/drm/gma500/mdfld_dsi_output.c @@ -92,8 +92,8 @@ void mdfld_dsi_brightness_init(struct mdfld_dsi_config *dsi_config, int pipe) { struct mdfld_dsi_pkg_sender *sender = mdfld_dsi_get_pkg_sender(dsi_config); - struct drm_device *dev = sender->dev; - struct drm_psb_private *dev_priv = dev->dev_private; + struct drm_device *dev; + struct drm_psb_private *dev_priv; u32 gen_ctrl_val; if (!sender) { @@ -101,6 +101,8 @@ void mdfld_dsi_brightness_init(struct mdfld_dsi_config *dsi_config, int pipe) return; } + dev = sender->dev; + dev_priv = dev->dev_private; /* Set default display backlight value to 85% (0xd8)*/ mdfld_dsi_send_mcs_short(sender, write_display_brightness, 0xd8, 1, true);