From patchwork Wed Dec 21 01:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yangxingui X-Patchwork-Id: 35232 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:e747:0:0:0:0:0 with SMTP id c7csp3288528wrn; Tue, 20 Dec 2022 18:05:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXudbnHVIkVqDy6MV7ibsUV8bxz7o0iJk7FF59RGu8U5VzDy2aJfoH0mfa+yGMimUF+JS2QE X-Received: by 2002:a05:6402:f8c:b0:474:4a60:bc6b with SMTP id eh12-20020a0564020f8c00b004744a60bc6bmr18527495edb.5.1671588357633; Tue, 20 Dec 2022 18:05:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671588357; cv=none; d=google.com; s=arc-20160816; b=jXeFE5mTAsFObzenJJNSgX5WsOomXAsFd7vsp7DQVmOm9TOWwl/Ssmfo47Urmuj1SU A2WiW5lMjQquZyX3plyZpcTp3t5+dQsklgnSbZ1byxLoemBxWp2LbHa6sv9sPKQNo2lC 0ujPwcJTygrbVNCLr917B6mCQ45jN59GCUDgy93v4Jtmr7VjCRuM3DkHjYj47egvzOCm H9EMo1WP/K7PdOfyGmh0azL47S4SjsN9GxMMpcyDjm4ZbsSloshWN65ENaXRaqroUWpJ L3N77C2cf8EfVDOOZsdp7q0jm/xihwC9jPozmerRc4IXnYaet9bIFjuYiQdOA8TCo+dU NHvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=0HTh9RTfSd0/lKmS50nVzTHoKXu8sZh6ivAtqBvoymk=; b=lD8hYoMZOpzgUIOIejyQq0Wqq2m/1D3zuFWo/FczUkAayFBTJSmPrsruz5IS0F2Ef3 dQFaVYhEhu80ywixoCfvYpy6Iia4M8XXH69Ite3TrCudMQTh0IwEoN35bKGnlf0lr4eH nvoWNM+KqW4k3cPJ3PZRLtuC7aWUkSTlIMQiJLUXpkCXN+i9+f/9jaRyGngwoElBXnmi vHyLxaLaNVQrcJoKOgss+6XcW0AqFETWAP5dLhQ+dW2D62s/VwxCsrCfSGTlt0jOgY8x 4IWTgweZof5rKHxh7h5C9ekXkXo0BVXr6Q7tF6iiRYtyYkBfwN3kcfGaaVN2s0ASZLup OP3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020a056402090d00b0047bb02c3cefsi4572014edz.265.2022.12.20.18.05.30; Tue, 20 Dec 2022 18:05:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234074AbiLUB6l (ORCPT + 99 others); Tue, 20 Dec 2022 20:58:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbiLUB6k (ORCPT ); Tue, 20 Dec 2022 20:58:40 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB257DFE; Tue, 20 Dec 2022 17:58:37 -0800 (PST) Received: from dggpemm500012.china.huawei.com (unknown [172.30.72.53]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NcGj70KtgzHqYZ; Wed, 21 Dec 2022 09:54:51 +0800 (CST) Received: from localhost.localdomain (10.67.165.24) by dggpemm500012.china.huawei.com (7.185.36.89) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 21 Dec 2022 09:58:36 +0800 From: Xingui Yang To: , , CC: , , , , , Subject: [PATCH v2] scsi: libsas: Fix did not grab the ata port lock in sas_ata_device_link_abort() Date: Wed, 21 Dec 2022 01:52:03 +0000 Message-ID: <20221221015203.46367-1-yangxingui@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500012.china.huawei.com (7.185.36.89) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752787433660638492?= X-GMAIL-MSGID: =?utf-8?q?1752787433660638492?= Grab the ata port lock in sas_ata_device_link_abort() before calling ata_link_abort(), as the comment in ata_link_abort() mentions. Fixes: 44112922674b ("scsi: libsas: Add sas_ata_device_link_abort()") Signed-off-by: Xingui Yang Reviewed-by: John Garry Reviewed-by: Jason Yan --- Changes to v1: - Add a fixes tag - Update commit message --- drivers/scsi/libsas/sas_ata.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c index f7439bf9cdc6..4f2017b21e6d 100644 --- a/drivers/scsi/libsas/sas_ata.c +++ b/drivers/scsi/libsas/sas_ata.c @@ -889,7 +889,9 @@ void sas_ata_device_link_abort(struct domain_device *device, bool force_reset) { struct ata_port *ap = device->sata_dev.ap; struct ata_link *link = &ap->link; + unsigned long flags; + spin_lock_irqsave(ap->lock, flags); device->sata_dev.fis[2] = ATA_ERR | ATA_DRDY; /* tf status */ device->sata_dev.fis[3] = ATA_ABORTED; /* tf error */ @@ -897,6 +899,7 @@ void sas_ata_device_link_abort(struct domain_device *device, bool force_reset) if (force_reset) link->eh_info.action |= ATA_EH_RESET; ata_link_abort(link); + spin_unlock_irqrestore(ap->lock, flags); } EXPORT_SYMBOL_GPL(sas_ata_device_link_abort);