From patchwork Tue Sep 5 23:15:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 721431 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 E025FCCF9E1 for ; Tue, 5 Sep 2023 23:17:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240992AbjIEXRg (ORCPT ); Tue, 5 Sep 2023 19:17:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240049AbjIEXRe (ORCPT ); Tue, 5 Sep 2023 19:17:34 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EBDE199 for ; Tue, 5 Sep 2023 16:17:31 -0700 (PDT) Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 385KnVxF009289; Tue, 5 Sep 2023 23:17:17 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=zeaxAonKaiQqN+p3SwlkicF8o+JQW42uspkAmXUybac=; b=oNCZXuMzwY7ktudraoRwia4D4jbz1/BjFujOGGtm4wXJAGbYuUw5XIqajYVUjjJYvTJU MONKHwx+mZ1UEMt1swemjnr8/y5ZSR5pd6exPBLyhkfnYDx9kISPyRTQh0QNC0NkCn1a M7idjFa+ez+NikvhAbNUFw7XvqrItlz55DhNgcTpdkX0aLw4a/bF8Y9wm4NQbU6iA+kv wQ3Kzwtyd4abMCVqtOgPvUkid2Og0jM4zRgb80YAlnqh7Z8y7QPKTM6AswcbthrAa2mQ ADISQ8hiemNLCBMdIbC1zF34Sm+bnWrIBMINRXAJK/wDEFmeDt54wlwa5pLdkPdXTjOM 2Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3sxbq3894h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 05 Sep 2023 23:17:17 +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 385LwVYh028173; Tue, 5 Sep 2023 23:17:17 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2173.outbound.protection.outlook.com [104.47.56.173]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3suug5e4hn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 05 Sep 2023 23:17:16 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bhrY2PhtU9EZ6uBSSJpAsARE3/7qfDk6dJ0SqQpm/wCl9QBV1vUP1zkZ7/Y9z4RnaWgTOKAk1CEr6lvHKQTwY3+HEYwth71781IyiLUiQ8nITZdTDgVlLgSYNaVJ6Ao3MemS+e1k+/BFsTyaZFYgEe+j5OcDESMssHVhSLVVcST0uhZWa6Dj5EausidK5V13LaNxKtGb5lQlpGoMWV98t96e3tmwUlo766+r2Oqbd1RCudZKDsa1tBHoX7v5ZBCOSOHIRL/woKALD77W3jFGxkNdM3P7+LWzAdHN5CzX3+orrbsf8u+18NC8kfMEkGK2A7F0c7puMlOtX1Vc2IMjlw== 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=zeaxAonKaiQqN+p3SwlkicF8o+JQW42uspkAmXUybac=; b=G1hAdYmRxNygUq50IksifycYxDPAF7iJkY37qPu19TlA5y6gGhWlao4JgQZVNB1jHgqPT+3Ks/U074YJ/TzsD+DbPVMr80tLv9893GO2L+eXhVnNaVbgR2Lf4w8rdzEIm4Xf67rfDKVSU5BdXKksjJij7kgpTyPM9bcSclGapnP0p3JDtV1777tFT47CZUB044YC/HQPBEl1AEO9s/lPYgXU3msFZPSLn9HlNjoX6RlAVAei9Tmr5bjPfF619B7k9djenkhSbiMiaXsk8N2E/ge45vP/fbIz9pMUcFBPytycWY8lMjiiXplDaGV8/VTDdxWiuAzTOwgWyq3fJNPv+A== 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=zeaxAonKaiQqN+p3SwlkicF8o+JQW42uspkAmXUybac=; b=PBKR6x3rLaBu1vBKVGR6ab6lX498jsALmMhh2HMbyh1hRPcTBJs81xsBJC4hZt4vtOoxqqMO9wxsIEVuLPClgph0CfImioahnguzmzsyqNPayhJVfaaHlOCnZueraVcrEb/qZ6p75EGZpDAFCmZKNp7PT0jVJZ2SIP+BRLHUUPA= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by PH7PR10MB5748.namprd10.prod.outlook.com (2603:10b6:510:131::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.33; Tue, 5 Sep 2023 23:17:14 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::2a3e:cf81:52db:a66a]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::2a3e:cf81:52db:a66a%4]) with mapi id 15.20.6745.030; Tue, 5 Sep 2023 23:17:14 +0000 From: Mike Christie To: john.g.garry@oracle.com, 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 v11 30/34] scsi: Fix sshdr use in scsi_test_unit_ready Date: Tue, 5 Sep 2023 18:15:43 -0500 Message-Id: <20230905231547.83945-31-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230905231547.83945-1-michael.christie@oracle.com> References: <20230905231547.83945-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0290.namprd03.prod.outlook.com (2603:10b6:5:3ad::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_|PH7PR10MB5748:EE_ X-MS-Office365-Filtering-Correlation-Id: a4177ebf-dc66-4596-561c-08dbae662ba5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UqLUsx26ixrHtKekPaQQIo2DVG2tYnJVSShzrIZUNzwiV/AhaklDL0AwLp6HgCvYuDMQRyDuJGoCjHkn/sgzQRcyvIAD71hF8M84KZoGQwaXP6fLuDM9lADpHD0lJaTnBErOOF3MfbVciNfpaTa5eGDvygxbet5n2BhhcGc13DQiw88C8taFiGrF+35+QxE+4Q1sVkNKb5uzGcTGTPUHy29ZP9s03LscnWIuufF4OYoGdsp7Ez3NvrmiZGurhv2zKMe403Xp/fWy7JwstI8AR2I4purDC0nZJDhovB1p1M7La19k5CMpKUhXdSO9TjRWPRh73hgdjIed3y3oUV1+cBeaAcBXwdcEUTn1X8XLckwifJMiJs39qTS2rpjuEHqOoPH/XxNv1qSLCWUkomMlUyx0bmE0P7eYR218vMkDZP3fKY7l3nhzsFVPM5AIOirJDA8Dx0fFxKSDdy4d8o5sk0qvhwh3K5P7WWz3ZymVh8Tfnu0sck2wEA7Gs6gR3On/te29lABdkDXGMy8iz472SIKWSuJlK8a2u0a7y8qtebo2DXVRfVYJFltKOo/aEFqU 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:(13230031)(396003)(366004)(39860400002)(346002)(136003)(376002)(186009)(451199024)(1800799009)(2906002)(38100700002)(36756003)(86362001)(41300700001)(6512007)(6506007)(6486002)(66556008)(316002)(66476007)(4326008)(8676002)(107886003)(66946007)(2616005)(8936002)(1076003)(6666004)(478600001)(26005)(5660300002)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1idkpEI8OaB1Ieu6+OlUAdXQQDWF2oK6wh7LiKl1IZDEwfwikWdh+H1TGVHPt0o5yQWSq/foug5G4xiIYJfExaKCIZcN259witPmONt2ggatBcgWDTwnPzvEIcPxJA/1S3E4LRBybvEnOEyu9qPQIhUOrKy16s5ZHF26hpV/rtCS6qmk+xebJrZnCL3xkd6Cq4anHe6aq/ukE63lJdpLB1sGx1Wf9NJNwfWMauE7yaSymbTfawtMEe1xcayuLam5fNDJEaAMOBqiQXmRendSKZ7bpj0pqheODxI+NVbQHx4bCOA+6RtJrWfCCOars+UpRDYYMW7tEPzkmmOeKQwe65AgOucFOObb+W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wvCIa178NmZNUoyohh7oDJN17trg6Ld9u2VyVwzq1mY0Ryl001i0WbHt/DG6bal5ydlAr6jMxJO3 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4177ebf-dc66-4596-561c-08dbae662ba5 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Sep 2023 23:16:44.6336 (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: hdS1TY86Vl75nWMddbooxVXVnjrITMVtflVYGL+3NWjjr7aTZNzhttgn42rwDcXg1T1FpaLCe/qWAzEX4JjDuJaeutYAJEhj7fnUDtWv3GU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR10MB5748 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-09-05_13,2023-09-05_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 adultscore=0 phishscore=0 bulkscore=0 mlxscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2308100000 definitions=main-2309050201 X-Proofpoint-GUID: jdPHArp9Wnfy4qp7fTOVRVQYVmx5xn6S X-Proofpoint-ORIG-GUID: jdPHArp9Wnfy4qp7fTOVRVQYVmx5xn6S Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we shouldn't access the sshdr. If it returns 0, then the cmd executed successfully, so there is no need to check the sshdr. This has us access the sshdr when we get a return value > 0. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: John Garry Reviewed-by: Martin Wilck --- drivers/scsi/scsi_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 67d74f175c4c..756e13637f15 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2319,10 +2319,10 @@ scsi_test_unit_ready(struct scsi_device *sdev, int timeout, int retries, do { result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, NULL, 0, timeout, 1, &exec_args); - if (sdev->removable && scsi_sense_valid(sshdr) && + if (sdev->removable && result > 0 && scsi_sense_valid(sshdr) && sshdr->sense_key == UNIT_ATTENTION) sdev->changed = 1; - } while (scsi_sense_valid(sshdr) && + } while (result > 0 && scsi_sense_valid(sshdr) && sshdr->sense_key == UNIT_ATTENTION && --retries); return result;