From patchwork Sun May 18 16:02:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rickard Strandqvist X-Patchwork-Id: 4198511 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@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 3015B9F1CD for ; Sun, 18 May 2014 16:02:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6EB0A2026C for ; Sun, 18 May 2014 16:02:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB3D120253 for ; Sun, 18 May 2014 16:02:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752035AbaERQCN (ORCPT ); Sun, 18 May 2014 12:02:13 -0400 Received: from mail-ee0-f41.google.com ([74.125.83.41]:34000 "EHLO mail-ee0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752025AbaERQCM (ORCPT ); Sun, 18 May 2014 12:02:12 -0400 Received: by mail-ee0-f41.google.com with SMTP id t10so2931251eei.28 for ; Sun, 18 May 2014 09:02:11 -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=f1QTsGWmxqwKQ3CZGATpYM3K1UvX1yd0mGbEjX+U2pA=; b=Y/uGmuEi+BjRHlCKn9gWkHIVt2JNLvqYMPTqssfKYSnkYOnk3viyPptlo8rqviGZAn 8CI8FFJ8LrQE9uOwZC6dzcRCrupNKm0cYVkb6ifRqI3iynCwKm6vpf1Y2wGxGLRBwyWt Mx77L2mpZGx0DDlutBxKmq08T1k/CSQacZ1KHeAMLTeUzU/lYVyGFOl6zNsHYl4PpK91 PmdG+g01F/SPQl1wnyD/lOA8mhFnk5+ZUWCowLUW+JqwRxLRrd7+2C9v1g+qG+rRCi1c QRDKNZ2p5IYGNdCK5C1+ifggVG+qX7AfLDRak/P7Bj67QmAYLSr0zbxgOHfnt3g5JcxT XPog== X-Gm-Message-State: ALoCoQntGYXDvQjYg0O52WhtQEqsVZBM0dtdwJ9Jnr1k6jrweRiagn3yLzcTeJkt0G2+TEIcsYW0 X-Received: by 10.14.94.5 with SMTP id m5mr39567345eef.23.1400428931148; Sun, 18 May 2014 09:02:11 -0700 (PDT) Received: from localhost.localdomain (h-245-62.a218.priv.bahnhof.se. [85.24.245.62]) by mx.google.com with ESMTPSA id a45sm35413624eez.2.2014.05.18.09.02.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 May 2014 09:02:10 -0700 (PDT) From: Rickard Strandqvist To: Bjorn Helgaas , Rickard Strandqvist Cc: "Rafael J. Wysocki" , Marta Rybczynska , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] pci: hotplug: cpqphp_ctrl.c: Fix for possible null pointer dereference Date: Sun, 18 May 2014 18:02:57 +0200 Message-Id: <1400428977-10464-1-git-send-email-rickard_strandqvist@spectrumdigital.se> X-Mailer: git-send-email 1.7.10.4 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 There is otherwise a risk of a possible null pointer dereference. Was largely found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist --- drivers/pci/hotplug/cpqphp_ctrl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/hotplug/cpqphp_ctrl.c b/drivers/pci/hotplug/cpqphp_ctrl.c index 11845b7..a319d07 100644 --- a/drivers/pci/hotplug/cpqphp_ctrl.c +++ b/drivers/pci/hotplug/cpqphp_ctrl.c @@ -709,7 +709,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz temp = temp->next; } - temp->next = max->next; + if(temp) + temp->next = max->next; } max->next = NULL;