From patchwork Wed Nov 4 21:50:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Brace X-Patchwork-Id: 7554051 Return-Path: X-Original-To: patchwork-linux-scsi@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 989109F2F7 for ; Wed, 4 Nov 2015 21:54:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BCF2B20604 for ; Wed, 4 Nov 2015 21:54:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA299205E7 for ; Wed, 4 Nov 2015 21:54:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030658AbbKDVyt (ORCPT ); Wed, 4 Nov 2015 16:54:49 -0500 Received: from bby1mta03.pmc-sierra.com ([216.241.235.118]:53421 "EHLO bby1mta03.pmc-sierra.bc.ca" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030228AbbKDVys (ORCPT ); Wed, 4 Nov 2015 16:54:48 -0500 Received: from bby1mta03.pmc-sierra.bc.ca (localhost.pmc-sierra.bc.ca [127.0.0.1]) by localhost (Postfix) with SMTP id 62D4910708E0; Wed, 4 Nov 2015 13:54:48 -0800 (PST) Received: from bby1uinfra02-temp.pmc-sierra.bc.ca (bby1uinfra02-temp.pmc-sierra.bc.ca [216.241.226.204]) by bby1mta03.pmc-sierra.bc.ca (Postfix) with ESMTP id 4055E10708CC; Wed, 4 Nov 2015 13:54:48 -0800 (PST) Received: from [127.0.1.1] (kirk.hou.lab.pmc-sierra.bc.ca [10.238.32.34]) by bby1uinfra02-temp.pmc-sierra.bc.ca (Postfix) with ESMTP id 98336E06DF; Wed, 4 Nov 2015 13:54:47 -0800 (PST) Subject: [PATCH v2 10/27] hpsa: fix hpsa_adjust_hpsa_scsi_table From: Don Brace To: scott.teel@pmcs.com, Kevin.Barnett@pmcs.com, scott.benesh@pmcs.com, james.bottomley@parallels.com, hch@infradead.org, Justin.Lindley@pmcs.com, elliott@hpe.com Cc: linux-scsi@vger.kernel.org Date: Wed, 04 Nov 2015 15:50:56 -0600 Message-ID: <20151104215056.15472.70511.stgit@brunhilda> In-Reply-To: <20151104214910.15472.23179.stgit@brunhilda> References: <20151104214910.15472.23179.stgit@brunhilda> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pmcs.com; h=subject:from:to:cc:date:message-id:in-reply-to:references:mime-version:content-type:content-transfer-encoding; s=default; bh=uqVV5FEkp61X2RP4mh4cGO5gZO7K5BLuf/Ix8KKtZPE=; b=Ip+vH6dcxYXLczX/RdhPfV5J8NwBlexd8MjFEJ1hm88gGL0FhBG0etfl9O1/A4BAPDVibXCbwzi0DmhFoHtC9rYwGZQ7NkxsfdkVaV8BwIbV0vmBc1viWwPOGEbdBdj8X77TuM+UJTAcmU41hb8mZ/5NM2CpICSK+R4HT0G+VzA= Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,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 NULL pointer issue in the driver when devices are removed during a reset. Signed-off-by: Don Brace Reviewed-by: Hannes Reinecke --- drivers/scsi/hpsa.c | 16 ++++++++++++++++ drivers/scsi/hpsa.h | 1 + 2 files changed, 17 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" 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 ae9968b..382cb5d 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -1663,6 +1663,15 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, int nadded, nremoved; struct Scsi_Host *sh = NULL; + /* + * A reset can cause a device status to change + * re-schedule the scan to see what happened. + */ + if (h->reset_in_progress) { + h->drv_req_rescan = 1; + return; + } + added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL); removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL); @@ -1771,6 +1780,10 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, goto free_and_out; sh = h->scsi_host; + if (sh == NULL) { + dev_warn(&h->pdev->dev, "%s: scsi_host is null\n", __func__); + goto free_and_out; + } /* Notify scsi mid layer of any removed devices */ for (i = 0; i < nremoved; i++) { if (removed[i] == NULL) @@ -5234,12 +5247,15 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd) hpsa_show_dev_msg(KERN_WARNING, h, dev, "resetting"); + h->reset_in_progress = 1; + /* send a reset to the SCSI LUN which the command was sent to */ rc = hpsa_do_reset(h, dev, dev->scsi3addr, HPSA_RESET_TYPE_LUN, DEFAULT_REPLY_QUEUE); snprintf(msg, sizeof(msg), "reset %s", rc == 0 ? "completed successfully" : "failed"); hpsa_show_dev_msg(KERN_WARNING, h, dev, msg); + h->reset_in_progress = 0; return rc == 0 ? SUCCESS : FAILED; } diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h index b173c0e..dc113c1a 100644 --- a/drivers/scsi/hpsa.h +++ b/drivers/scsi/hpsa.h @@ -271,6 +271,7 @@ struct ctlr_info { wait_queue_head_t abort_cmd_wait_queue; wait_queue_head_t event_sync_wait_queue; struct mutex reset_mutex; + u8 reset_in_progress; }; struct offline_device_entry {