From patchwork Wed Jul 2 21:45:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rickard Strandqvist X-Patchwork-Id: 4468131 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 800849F26C for ; Wed, 2 Jul 2014 21:44:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A9BB820384 for ; Wed, 2 Jul 2014 21:44:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C7018202E5 for ; Wed, 2 Jul 2014 21:44:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757312AbaGBVoi (ORCPT ); Wed, 2 Jul 2014 17:44:38 -0400 Received: from mail-wi0-f169.google.com ([209.85.212.169]:38100 "EHLO mail-wi0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754947AbaGBVoh (ORCPT ); Wed, 2 Jul 2014 17:44:37 -0400 Received: by mail-wi0-f169.google.com with SMTP id hi2so9709288wib.2 for ; Wed, 02 Jul 2014 14:44:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tJkJYOw8Oc4ZPsRrJr4GlB26d0uYOSK2YVuTsfMbyl0=; b=YlG0OSwT8kG2D+7aPovS9RJF1z1zFpXTePWigjpmGuqFc2mvHzYRxoJJIdaqcXXIB4 MIEeHcFFejT1LZE5yEH1QM4sohMYZxSjxgE6vcrvrsQE2/e0YRxcbpIgHaVoYTpHnbGM qJUSA1cOCK8HXGch5h7Qw+p3r0xi0RvwyHCFhrlGSpbyR9IkgYj5aMffTS6jz8hyWnzx 3WtAIcl4dYefcHy3SO5S4mcoqR07kkpxZYpRTExA83HFDAUad6tsMDXeHD9yVhF4vCRe 5p5JS1M7hSYXxnkghUcUyS+V1waNHp4LISGkbFg1s33HnRBKl0pEvfG9LFFgmeeI/cSq 5+rQ== X-Gm-Message-State: ALoCoQmGiS5efgNgrj/04jLnZWL4fECm2pwzr/4SleAO3Vbq7dMFMw+FEEenOQZryMg9QNigfLkp X-Received: by 10.180.90.132 with SMTP id bw4mr37070380wib.42.1404337476423; Wed, 02 Jul 2014 14:44:36 -0700 (PDT) Received: from localhost.localdomain (h-245-62.a218.priv.bahnhof.se. [85.24.245.62]) by mx.google.com with ESMTPSA id i4sm59456294wib.21.2014.07.02.14.44.34 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Jul 2014 14:44:35 -0700 (PDT) From: Rickard Strandqvist To: Jean-Christophe Plagniol-Villard , Tomi Valkeinen Cc: Rickard Strandqvist , Jingoo Han , Alexandru Juncu , Mikulas Patocka , Daniel Vetter , Joe Perches , linux-fbdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] video: fbdev: matrox: matroxfb_base.c: Fix for possible null pointer dereference Date: Wed, 2 Jul 2014 23:45:51 +0200 Message-Id: <1404337551-6499-1-git-send-email-rickard_strandqvist@spectrumdigital.se> X-Mailer: git-send-email 1.7.10.4 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Fix a possible null pointer dereference, there is otherwise a risk of a possible null pointer dereference This was found using a static code analysis program called cppcheck Signed-off-by: Rickard Strandqvist --- drivers/video/fbdev/matrox/matroxfb_base.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/matrox/matroxfb_base.c b/drivers/video/fbdev/matrox/matroxfb_base.c index 7116c53..85ef84b 100644 --- a/drivers/video/fbdev/matrox/matroxfb_base.c +++ b/drivers/video/fbdev/matrox/matroxfb_base.c @@ -1971,9 +1971,9 @@ static void matroxfb_register_device(struct matrox_fb_info* minfo) { int i = 0; list_add(&minfo->next_fb, &matroxfb_list); for (drv = matroxfb_driver_l(matroxfb_driver_list.next); - drv != matroxfb_driver_l(&matroxfb_driver_list); + drv && drv != matroxfb_driver_l(&matroxfb_driver_list); drv = matroxfb_driver_l(drv->node.next)) { - if (drv && drv->probe) { + if (drv->probe) { void *p = drv->probe(minfo); if (p) { minfo->drivers_data[i] = p;