From patchwork Mon Jan 8 10:51:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hannes Reinecke X-Patchwork-Id: 10149259 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 537226056F for ; Mon, 8 Jan 2018 10:52:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47BAA1FFDA for ; Mon, 8 Jan 2018 10:52:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C7AD26212; Mon, 8 Jan 2018 10:52:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF99B1FFDA for ; Mon, 8 Jan 2018 10:52:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756685AbeAHKv7 (ORCPT ); Mon, 8 Jan 2018 05:51:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:51577 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756683AbeAHKv7 (ORCPT ); Mon, 8 Jan 2018 05:51:59 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0DB9BACC6; Mon, 8 Jan 2018 10:51:58 +0000 (UTC) From: Hannes Reinecke To: "Martin K. Petersen" Cc: Christoph Hellwig , James Bottomley , linux-scsi@vger.kernel.org, Yves-Alexis Perez , Hannes Reinecke , Hannes Reinecke Subject: [PATCH] libsas: Check for completed commands before calling lldd_abort_task() Date: Mon, 8 Jan 2018 11:51:56 +0100 Message-Id: <1515408716-102111-1-git-send-email-hare@suse.de> X-Mailer: git-send-email 1.8.5.6 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The abort handler might be racing with command completion, so the task might already be NULL by the time the abort handler is called. Signed-off-by: Hannes Reinecke --- drivers/scsi/libsas/sas_scsi_host.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c index 58476b7..ae2ae3c 100644 --- a/drivers/scsi/libsas/sas_scsi_host.c +++ b/drivers/scsi/libsas/sas_scsi_host.c @@ -486,7 +486,7 @@ static int sas_queue_reset(struct domain_device *dev, int reset_type, int sas_eh_abort_handler(struct scsi_cmnd *cmd) { - int res; + int res = TMF_RESP_FUNC_COMPLETE; struct sas_task *task = TO_SAS_TASK(cmd); struct Scsi_Host *host = cmd->device->host; struct sas_internal *i = to_sas_internal(host->transportt); @@ -494,7 +494,8 @@ int sas_eh_abort_handler(struct scsi_cmnd *cmd) if (!i->dft->lldd_abort_task) return FAILED; - res = i->dft->lldd_abort_task(task); + if (task) + res = i->dft->lldd_abort_task(task); if (res == TMF_RESP_FUNC_SUCC || res == TMF_RESP_FUNC_COMPLETE) return SUCCESS;