From patchwork Mon Apr 14 15:45:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Bottomley X-Patchwork-Id: 3983271 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 64F259F336 for ; Mon, 14 Apr 2014 15:46:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 90EDD201D3 for ; Mon, 14 Apr 2014 15:45:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A7F58201B4 for ; Mon, 14 Apr 2014 15:45:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754444AbaDNPpW (ORCPT ); Mon, 14 Apr 2014 11:45:22 -0400 Received: from bedivere.hansenpartnership.com ([66.63.167.143]:54911 "EHLO bedivere.hansenpartnership.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754239AbaDNPpU (ORCPT ); Mon, 14 Apr 2014 11:45:20 -0400 Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 433EF8EE1B8; Mon, 14 Apr 2014 08:45:19 -0700 (PDT) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rqhJm87uGBaW; Mon, 14 Apr 2014 08:45:19 -0700 (PDT) Received: from [153.66.254.224] (c-50-135-59-229.hsd1.wa.comcast.net [50.135.59.229]) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 74EC18EE065; Mon, 14 Apr 2014 08:45:18 -0700 (PDT) Message-ID: <1397490316.2207.23.camel@dabdike.int.hansenpartnership.com> Subject: Re: [PATCH] hpsa: fix uninitialized trans_support in hpsa_put_ctlr_into_performant_mode() From: James Bottomley To: scameron@beardog.cce.hp.com Cc: Bjorn Helgaas , Davidlohr Bueso , Baoquan He , "linux-kernel@vger.kernel.org" , linux-scsi , "linux-pci@vger.kernel.org" , Joerg Roedel , "open list:INTEL IOMMU (VT-d)" , Jiang Liu Date: Mon, 14 Apr 2014 08:45:16 -0700 In-Reply-To: <20140410221704.GA22465@beardog.cce.hp.com> References: <20140410221704.GA22465@beardog.cce.hp.com> X-Mailer: Evolution 3.10.2 Mime-Version: 1.0 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.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Your subject line is very tame. It should be the one line summary of why we apply the patch, so it should read something like hpsa: fix NULL deref in performant mode On Thu, 2014-04-10 at 17:17 -0500, scameron@beardog.cce.hp.com wrote: > Without this, you'll see a null pointer dereference in > hpsa_enter_performant_mode(). The description should be more comprehensible. I'm clear that the use before initialisation is a bug ... I'm less clear on why it causes an oops. > Signed-off-by: Stephen M. Cameron > --- > drivers/scsi/hpsa.c | 4 ++++ > 1 files changed, 4 insertions(+), 0 deletions(-) > > diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c > index 8cf4a0c..ef4dfdd 100644 > --- a/drivers/scsi/hpsa.c > +++ b/drivers/scsi/hpsa.c > @@ -7463,6 +7463,10 @@ static void hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) > if (hpsa_simple_mode) > return; > > + trans_support = readl(&(h->cfgtable->TransportSupport)); > + if (!(trans_support & PERFORMANT_MODE)) > + return; > + > /* Check for I/O accelerator mode support */ > if (trans_support & CFGTBL_Trans_io_accel1) { > transMethod |= CFGTBL_Trans_io_accel1 | Shouldn't you be moving this check from its previous location, rather than adding a new one that makes the original obsolete? James --- -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 8cf4a0c..9a6e4a2 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -7463,6 +7463,10 @@ static void hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) if (hpsa_simple_mode) return; + trans_support = readl(&(h->cfgtable->TransportSupport)); + if (!(trans_support & PERFORMANT_MODE)) + return; + /* Check for I/O accelerator mode support */ if (trans_support & CFGTBL_Trans_io_accel1) { transMethod |= CFGTBL_Trans_io_accel1 | @@ -7479,10 +7483,6 @@ static void hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) } /* TODO, check that this next line h->nreply_queues is correct */ - trans_support = readl(&(h->cfgtable->TransportSupport)); - if (!(trans_support & PERFORMANT_MODE)) - return; - h->nreply_queues = h->msix_vector > 0 ? h->msix_vector : 1; hpsa_get_max_perf_mode_cmds(h); /* Performant mode ring buffer and supporting data structures */