From patchwork Thu Jun 20 00:01:47 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 2752461 Return-Path: X-Original-To: patchwork-intel-gfx@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 53920C0AB1 for ; Thu, 20 Jun 2013 00:02:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B551220178 for ; Thu, 20 Jun 2013 00:02:00 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6DEEC20319 for ; Thu, 20 Jun 2013 00:01:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 21E66E5DFA for ; Wed, 19 Jun 2013 17:01:59 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-bk0-f44.google.com (mail-bk0-f44.google.com [209.85.214.44]) by gabe.freedesktop.org (Postfix) with ESMTP id C1108E5C80; Wed, 19 Jun 2013 17:01:48 -0700 (PDT) Received: by mail-bk0-f44.google.com with SMTP id r7so2630686bkg.31 for ; Wed, 19 Jun 2013 17:01:47 -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=hRdP3I7sIGPvQkw4us/lFY9boPpm2P4fnoX6D3y9EUo=; b=DVVb8BHO0y9TLolGorLEN64Z3zfPCupBE1dbQfU3QOpikgROgu9YA5BD4wOulTiEjK Sqy7UPan3aPpEmBmN09CEO7SHc8qWBUDMy/gE5V9krIX5Q8cPZW1dv8kQHHG16t5oVoW Eo6rkGv5TvAHq7RlFhLY2MUDQOSjE+kn/onAL+IPl5w0EYYAo3bkwltKoj36LxYzk7h5 ZZsbvtk5gCSqlEYN1EbKqaoJOoJakFMqoUQj1OP880EHZ/Im/KJEoZ/d04jO5t1tZpZW XSG0pSDX7xyUVCjGdYGlrG3W86RBX1WoYoD8n0wKZijEN+tDn1v9gZxYb73tkwDBEluw 8LOQ== MIME-Version: 1.0 X-Received: by 10.204.189.80 with SMTP id dd16mr686123bkb.126.1371686507766; Wed, 19 Jun 2013 17:01:47 -0700 (PDT) Received: by 10.204.42.138 with HTTP; Wed, 19 Jun 2013 17:01:47 -0700 (PDT) Date: Thu, 20 Jun 2013 08:01:47 +0800 Message-ID: From: Wei Yongjun To: daniel.vetter@ffwll.ch, airlied@linux.ie Cc: yongjun_wei@trendmicro.com.cn, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [Intel-gfx] [PATCH -next] drm/i915: fix potential NULL pointer dereference in i915_gem_context_get_hang_stats() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-5.4 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 should be moved below the NULL test. Signed-off-by: Wei Yongjun --- drivers/gpu/drm/i915/i915_gem_context.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index ff47145..f32107e 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -309,7 +309,7 @@ i915_gem_context_get_hang_stats(struct intel_ring_buffer *ring, u32 id) { struct drm_i915_private *dev_priv = ring->dev->dev_private; - struct drm_i915_file_private *file_priv = file->driver_priv; + struct drm_i915_file_private *file_priv; struct i915_hw_context *to; if (dev_priv->hw_contexts_disabled) @@ -321,6 +321,7 @@ i915_gem_context_get_hang_stats(struct intel_ring_buffer *ring, if (file == NULL) return ERR_PTR(-EINVAL); + file_priv = file->driver_priv; if (id == DEFAULT_CONTEXT_ID) return &file_priv->hang_stats;