From patchwork Mon Jul 20 12:29:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 6826951 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 275979F38B for ; Mon, 20 Jul 2015 12:29:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3D5D420481 for ; Mon, 20 Jul 2015 12:29:43 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 685AE20662 for ; Mon, 20 Jul 2015 12:29:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 849226E197; Mon, 20 Jul 2015 05:29:40 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pd0-f170.google.com (mail-pd0-f170.google.com [209.85.192.170]) by gabe.freedesktop.org (Postfix) with ESMTPS id 971A36E108; Mon, 20 Jul 2015 05:29:39 -0700 (PDT) Received: by pdbbh15 with SMTP id bh15so55733205pdb.1; Mon, 20 Jul 2015 05:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=xXBcZJOi+h80ixr6TRE1mfs20GyVvGj9UTsq1P9/JtU=; b=PbY87fpn9QEnyZsEydcn+UvFigYLMrBzXIlg+ibPDHq8Fqq6dUrb6QD9bQf+xPjx69 WkXAAHNBZBRYLBv0La4YsVdD/ND2NJ18tz3XTtaCH9EHb7JlXbY4sdSMjCvY68u00T1k fFvhLT16kP5Ey2oJY7gPjgKxal5Tan+5Be2ElQkktulQvj+eYEFHLWTuCSr/pskVFGbq MAGaBD4jClO3oExmJCsCgS5DHsYKtLUmnuqHZoTq5fV2AOjc63/ijuTRUT4ZFy1DhDFZ gpkFStGJ/MSPluvZPtbnm7KUnwLiEJPxodnLAog83d4BEao/HxLUF/ZsOWksniP1bi6F iIRA== X-Received: by 10.70.34.171 with SMTP id a11mr59343357pdj.18.1437395379118; Mon, 20 Jul 2015 05:29:39 -0700 (PDT) Received: from localhost.localdomain ([49.206.252.123]) by smtp.gmail.com with ESMTPSA id a4sm6661223pdm.85.2015.07.20.05.29.36 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 20 Jul 2015 05:29:38 -0700 (PDT) From: Sudip Mukherjee To: Daniel Vetter , Jani Nikula , David Airlie Subject: [PATCH] drm/i915: fix possible null pointer dereference Date: Mon, 20 Jul 2015 17:59:29 +0530 Message-Id: <1437395369-749-1-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.8.1.2 Cc: intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Sudip Mukherjee X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-5.3 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 We were dereferencing dev first and then checking if it is NULL. Lets check for NULL first and then dereference. Signed-off-by: Sudip Mukherjee --- drivers/gpu/drm/i915/i915_debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c index bc817da..f316e49 100644 --- a/drivers/gpu/drm/i915/i915_debugfs.c +++ b/drivers/gpu/drm/i915/i915_debugfs.c @@ -4100,12 +4100,13 @@ static int i915_displayport_test_active_show(struct seq_file *m, void *data) { struct drm_device *dev = m->private; struct drm_connector *connector; - struct list_head *connector_list = &dev->mode_config.connector_list; + struct list_head *connector_list; struct intel_dp *intel_dp; if (!dev) return -ENODEV; + connector_list = &dev->mode_config.connector_list; list_for_each_entry(connector, connector_list, head) { if (connector->connector_type !=