From patchwork Sun Oct 7 13:56:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 1562171 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 850D2DFF71 for ; Sun, 7 Oct 2012 23:18:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 60BF49F036 for ; Sun, 7 Oct 2012 16:18:06 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qc0-f181.google.com (mail-qc0-f181.google.com [209.85.216.181]) by gabe.freedesktop.org (Postfix) with ESMTP id B2A979EB2F for ; Sun, 7 Oct 2012 06:56:45 -0700 (PDT) Received: by mail-qc0-f181.google.com with SMTP id x40so2630031qcp.26 for ; Sun, 07 Oct 2012 06:56:45 -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=Yp5CaVPUnf2tprJhQFWaqGWehN7ObwaTYqVIZ3HQHRI=; b=r7wHs86Wp7S+RHv+YD0HugJF30yzjHwApXFF8Yih0XHapeAmNEoLpOc5qh/5Z74Wi6 VjwVKyIPNOMaYcr4eCeVoqpaiFJAUd+2c6cXlEEZ22uroY1PRtG7snDTLecjS2I/5tv7 RtZyFzMiYDrxCzhQq/2PJmAO35dY3+HAWqnYvctMm7Tasau1R2x1ma7OgEPcnDDoqvjW EAzJjptU0Ijrsa7dg3w5MH3Z0AhjHrtEgwppBPipN30ec4wOxlebmMy8bVJ76Xz3KGiE jFWLYX3u0Rr1hJWhAIgpIIAvFos8OAzdxGQ8CgxdIr+ycvQ3X6MkCk+SWKTWcfCLWshl t/yg== MIME-Version: 1.0 Received: by 10.224.100.200 with SMTP id z8mr25603666qan.75.1349618205055; Sun, 07 Oct 2012 06:56:45 -0700 (PDT) Received: by 10.229.146.194 with HTTP; Sun, 7 Oct 2012 06:56:45 -0700 (PDT) Date: Sun, 7 Oct 2012 21:56:45 +0800 Message-ID: Subject: [PATCH] gma500: medfield: fix potential NULL pointer dereference in mdfld_dsi_output_init() From: Wei Yongjun To: airlied@linux.ie X-Mailman-Approved-At: Sun, 07 Oct 2012 16:15:28 -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 From: Wei Yongjun The dereference should be moved below the NULL test. dpatch engine is used to auto generate this patch. (https://github.com/weiyj/dpatch) Signed-off-by: Wei Yongjun --- drivers/gpu/drm/gma500/mdfld_dsi_output.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/gma500/mdfld_dsi_output.c b/drivers/gpu/drm/gma500/mdfld_dsi_output.c index 32dba2a..f92932f 100644 --- a/drivers/gpu/drm/gma500/mdfld_dsi_output.c +++ b/drivers/gpu/drm/gma500/mdfld_dsi_output.c @@ -500,17 +500,18 @@ void mdfld_dsi_output_init(struct drm_device *dev, struct mdfld_dsi_connector *dsi_connector; struct drm_connector *connector; struct mdfld_dsi_encoder *encoder; - struct drm_psb_private *dev_priv = dev->dev_private; + struct drm_psb_private *dev_priv; struct panel_info dsi_panel_info; u32 width_mm, height_mm; - dev_dbg(dev->dev, "init DSI output on pipe %d\n", pipe); - if (!dev || ((pipe != 0) && (pipe != 2))) { DRM_ERROR("Invalid parameter\n"); return; } + dev_dbg(dev->dev, "init DSI output on pipe %d\n", pipe); + dev_priv = dev->dev_private; + /*create a new connetor*/ dsi_connector = kzalloc(sizeof(struct mdfld_dsi_connector), GFP_KERNEL); if (!dsi_connector) {