From patchwork Wed Jun 14 07:17:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13279621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C735FEB64DB for ; Wed, 14 Jun 2023 07:22:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234403AbjFNHWO (ORCPT ); Wed, 14 Jun 2023 03:22:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234394AbjFNHVa (ORCPT ); Wed, 14 Jun 2023 03:21:30 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7C6F2101 for ; Wed, 14 Jun 2023 00:20:33 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35E6k02v012014; Wed, 14 Jun 2023 07:17:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=pQ5x4e5F0/nfYtGXX5LiHsm1alVkiIUxO6MyqQE11gA=; b=dceZebATFM+oyGeYwjxmIJfdym/LvTZWmGHe9/8HQtyzR4/K1SY7VE4BXAbCvkqVboqQ +PiY4IJyjkuCFvjq8zdKfZhUt3TVpQ8ExIPD2TrdkN6OQ258BOJ7NIaBBtt8v8x3W2/i vjNqUb4N9F96AXkWa/UOZyljzdpyekgviPQUz0ofeQpwG/4tankHZCytKE24vYa4uG4u q2TlT11ctdKCIv/EJ8T77dPlCzuIJ92Oni4QmMkZyFQXVnbG6MpRnJo51aQl9FMRNH0l AhugPyb3i4vR02JjJG7anUxun7e/x1J7Q2QRA7LeUeW4v5L121SYKivc9xseK2RX3lyP 9Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3r4fs1xxwc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Jun 2023 07:17:51 +0000 Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35E5NeEW017722; Wed, 14 Jun 2023 07:17:50 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2041.outbound.protection.outlook.com [104.47.73.41]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3r4fm4wsc9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 14 Jun 2023 07:17:50 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eznJWfq4hxrUfGWY8wvTrmhZX8+7XoQX3NRwWvwMCvktlWDQWPqcQ8ze5l3n4otBp9bVyQxImxHfcInFSA9giVZHMlffh2iDj/sw2FBVdBK2O021Gkoe088DU4Spb/9A28fKnfIkUGf9aO0Eaz9V1LM/vmpfsbGmDCN7orSolIaurD3TCJQDP2tz0Oqs6gf5vMr9cnuk8jgzaV/+KGhp/zx2n0LTGrYRtvzbCwiVquRHiU0+yNVQvrOad7PJWIuXUr5xlVxk2wxBn8LBIHM5abYnqWLruT++h3T6cOOrjz3dGuv/k8X6Xx9SGKY6s0ZvVANiDG4C+xBLklUhb1n15Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=pQ5x4e5F0/nfYtGXX5LiHsm1alVkiIUxO6MyqQE11gA=; b=DzdWb+4TKQcxi9jhMsXF/6xCFQ/e+mc/WcokaxdmPhNVFMK/olQeYxZkHMkpIBWnHg4wjRrBfcCWHP2cW6fYwFC3E1DQuiKTyPa1zjnYq50VHlNXxZGrqM9lSDvNBGfkkUQikMypcgDP5p2QGHlgJ5p79fGC8DSksFW37Wc3PsSt75/myAQzsMbmnK97eTJesUp17QPqdi7TdcaE+z1xe3Fb/F0O1kPh3G+HyobzkA5Uw302TbTXPmtuORCEbLC7Nmb3t7W1J+8EWsE//GL2YjxsemewB9EezSCO3vlW0IBUDQlh4vM2qYHHLc1Qzr/OXVwQRsTJDF5++1mBbDEbhg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pQ5x4e5F0/nfYtGXX5LiHsm1alVkiIUxO6MyqQE11gA=; b=YRyFBynG/3zLbU1k67QUTVdRfbTCtD1OOmgr68Kud5hkBC0k+dG31ekokg6SmazWNMLT9TPz3hXY6yRJOWTXrsvj/7/yE4K23/vHj5AQDYaV+Cs81wLYwRD9JJevZ1P4PMlAKVlVCKfgtE2e6JOTjATyusFti1PUBbdP1bukoro= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by SN7PR10MB7030.namprd10.prod.outlook.com (2603:10b6:806:349::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6477.29; Wed, 14 Jun 2023 07:17:48 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::13d6:c3f3:2447:6559]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::13d6:c3f3:2447:6559%5]) with mapi id 15.20.6455.045; Wed, 14 Jun 2023 07:17:48 +0000 From: Mike Christie To: bvanassche@acm.org, mwilck@suse.com, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH v8 15/33] scsi: spi: Fix sshdr use Date: Wed, 14 Jun 2023 02:17:01 -0500 Message-Id: <20230614071719.6372-16-michael.christie@oracle.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230614071719.6372-1-michael.christie@oracle.com> References: <20230614071719.6372-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7P222CA0022.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::25) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|SN7PR10MB7030:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b74a2e3-1d15-4b67-2903-08db6ca77546 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bt6veXCO/1e/hRHmN7eW3rRdm/IynwcbA3HlqMDhtZIhk01D67FoID6Bf0HqrX0WogKG4KgZiZ/O+8OQF/BA435lMu6NyU7p9vhTdlIEAPHBfIb2BXOnswXBVJrJQ0toEah3IvVl1waQv+2EisPDJ7lkSzULAqL2eLI0HKFrSGsfk90S6xSN6kNAWzi2BhgwG0xgpeVdZqgiCKcgvG9OSdLbOKNX+v6uh/MCK78+sxJ+6TdAW3fRpCaVmZJcEAZfo68tOt8gp8oxgBGutK/yD41fmBBEu02Pxe3iGLnQ5FqYBVc88TF5Wr8fVmEu9THoxEZIKRl6ff5wEKHU0+VtgDKrE7/O99LS9lJ2X14GUYx8MW1rZHOjG4wVdYEAlONHHDVgVV6ljl+H/xz6Gby6LdjQXC8c6GQXdtIWRum8bkkytT3CtuW1i2awGhdbQDyQrdBOU9QlrFVEd5yMZmA+jkbdaGRh/l4Qobfaei0RVsivx52or/ZGQs4KozuGf4quzDS53KWn90WvooFDO75l7le68D28Qtp9cX3zGPOZhrOHgC9JNv6Of2Ee1lkpgTVV X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY8PR10MB7243.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(136003)(39860400002)(366004)(376002)(396003)(346002)(451199021)(66946007)(66476007)(66556008)(478600001)(5660300002)(8936002)(6666004)(4326008)(8676002)(36756003)(41300700001)(6486002)(316002)(38100700002)(107886003)(26005)(186003)(6512007)(1076003)(6506007)(2616005)(2906002)(83380400001)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: a+0mCJAV80dDgIo77VB79fRHFDCVhEbLpzZ2mFTBHBcRBWMHrKVE5Ov+xwmmFfhawCqN/7wMQ3ug7sfZW7wdrTP3R3f9u95x+uVJQNqCUBGeLGDlXRDh7b5hscR+jEoIlRc8teHz28GvNfZQbGe5iAVRFfoyMicyO6zVTw1H3FjKXs8tpkNQJt7DS82RwrwMwhXaYIIIgD3/FI9mzcEY0mUuMsEJrtQZfzBhdmrax/eKyZo5MWbQMjUeA/N0z2aJ6bwENgZQwff6rxmFx60p+7kk3M6rBjacik/hmIbD21JqzjVwDwss/mFkn1csA4dHdGKLoIFj5M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hakPny25qk3YRIoORzKgNXxK65zy8p1V/Ky3R9APGIhjnKX6MjUorbPztqDm8h/TcfhCcXCnAihbOiGY3najmhtFqEq5QyNZHSA X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b74a2e3-1d15-4b67-2903-08db6ca77546 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jun 2023 07:17:48.7085 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: YkgCEoG3T/3Dl/3RW1xvBz5l3Hqa8hTpOPe0EZaVG/AVMYdRT/ahUWQ25oR4s60TtyQxBSMLgk66jbKvIAVoEcoSxlAJduMzUN7i+M5hbcA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR10MB7030 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.176.26 definitions=2023-06-14_04,2023-06-12_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 malwarescore=0 suspectscore=0 mlxlogscore=999 mlxscore=0 phishscore=0 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306140062 X-Proofpoint-GUID: lD40UBDaeGrEopfBPwtoDZjv-Zda43yl X-Proofpoint-ORIG-GUID: lD40UBDaeGrEopfBPwtoDZjv-Zda43yl Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If scsi_execute_cmd returns < 0 it will not have set the sshdr, so we can't access it. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig --- drivers/scsi/scsi_transport_spi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 2442d4d2e3f3..2100c3adb456 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -126,7 +126,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd, */ result = scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen, DV_TIMEOUT, 1, &exec_args); - if (result < 0 || !scsi_sense_valid(sshdr) || + if (result <= 0 || !scsi_sense_valid(sshdr) || sshdr->sense_key != UNIT_ATTENTION) break; } @@ -676,10 +676,10 @@ spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer, for (r = 0; r < retries; r++) { result = spi_execute(sdev, spi_write_buffer, REQ_OP_DRV_OUT, buffer, len, &sshdr); - if(result || !scsi_device_online(sdev)) { + if (result || !scsi_device_online(sdev)) { scsi_device_set_state(sdev, SDEV_QUIESCE); - if (scsi_sense_valid(&sshdr) + if (result > 0 && scsi_sense_valid(&sshdr) && sshdr.sense_key == ILLEGAL_REQUEST /* INVALID FIELD IN CDB */ && sshdr.asc == 0x24 && sshdr.ascq == 0x00)