From patchwork Tue Oct 3 20:50: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: 729203 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 86D4AE8FDB8 for ; Tue, 3 Oct 2023 20:51:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241089AbjJCUvQ (ORCPT ); Tue, 3 Oct 2023 16:51:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232190AbjJCUvP (ORCPT ); Tue, 3 Oct 2023 16:51:15 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC84AAC for ; Tue, 3 Oct 2023 13:51:10 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 393I54qK019675; Tue, 3 Oct 2023 20:51:02 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=aUEazPO19jsmAjR7IDQiI5HKb/28GrPnYqAxS4TmsS8=; b=vD/nnf+8pFYzdTR76qR9DSDkrqaKGVwxt5iMlalj8gWuOQOu/swywYOWeAn2pLD6UbzZ Jaak+mJ+VoGyym7ko53AQ8+10N1nVfxfHoqPRZp8Q4EoEm0g+GtrHge25KsE19NQhL9u PnJ07LdxM6PECvMsoRYffcf2ltOZ4sSYFWjz+Reu/Ayum+WZJLqKk/2VOo/qubbf18Mu gvfdfDt8cBCPZxHuhIIt780gZsGgGw/7+4OouKHBj5tH+JZhk3kb/PoMOay5+ScPRR0J WE8tGk6IH5+yWyQ6rVEj/BNEkdEDWElhFlni1T2hz2X/n8tbwMuLTs/P6azQYo0aaBw6 +Q== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tebjbwnsh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:01 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 393K0bYv025731; Tue, 3 Oct 2023 20:51:00 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tea4d11hd-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nZPZE7MC8I2mR3dEk6UbNfHCqYNs7aRGI2mXyHRC5sOI6bOJ9AFpcY4bLr/xss0z91oo9ikEGI0k/FOJ9XN8Wlu513bE6oW5zh2sfcxZN3TeHv7xiqHognU6lyv36gJnKG1jrm8uIqBr0trV1Wn98q4FMrJUatb5VW8o6kcJmJC7MeM3Tc0Jcwcmq/VtT1+EPReIyDhGfZ5mz+44QDarxyw0HZa1876y7tO4O8Uo894H1g86jvgoavWmZJa9N9pLoP6bLpDsz4z5pnzNtpGNHFocHqOnEJcV98tx6MMjL440WuFG8SXE1SOnr3InKljVWUYg3wJjKe5wHUVWvGHPxw== 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=aUEazPO19jsmAjR7IDQiI5HKb/28GrPnYqAxS4TmsS8=; b=dAmDt02gxWbUzWQYmTmBmbxh643y+HSW83TZnC9i1rr8bUOMCfO9K03AO6bOw7MZaOe4tT7K+OHZERzXNtPXSZi1KT33coOnDmPlooKFin7g+f1u8ZcSu40Rh1CpId0Ce7v0kUhrdjYhO6ScVA16jeDM45tEIX3zw3Pc/abWETIRQCqFMytiH0q72e61Iutg/5kHxCQAP4Ef/oXHYZ4a4/t9g9L6OrC7zy/ycRlwVmU1FVhmhhszxKyxb7CM7Ctw7KOxzjNKSDVvtb4oB02sKlhyEcUy9oGSxj8k7VSv4upSHRv0hE8sVB22U0msKJRRx5rKvcXJGCFlikM6henUDA== 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=aUEazPO19jsmAjR7IDQiI5HKb/28GrPnYqAxS4TmsS8=; b=cFuy0lLNESxPO9cjkpWjBvbR3PZA2xNfTvJiUVhxlVFy67YZCKCfB3Sy+Aq78I9vLcfMb9V5H35LGkS0/y9l7pnQS8Lpoipa2gDnNkwusCH9j0BzlhBbh1hz+9V992ETtRMhL5xlgEtrTNwWo5nU5TJ7vko6pZc62PT5IJxKp8w= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by IA0PR10MB6794.namprd10.prod.outlook.com (2603:10b6:208:43a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 20:50:58 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6838.028; Tue, 3 Oct 2023 20:50:58 +0000 From: Mike Christie To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH 01/12] scsi: sd: Fix sshdr use in read_capacity_16 Date: Tue, 3 Oct 2023 15:50:43 -0500 Message-Id: <20231003205054.84507-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003205054.84507-1-michael.christie@oracle.com> References: <20231003205054.84507-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR02CA0127.namprd02.prod.outlook.com (2603:10b6:5:1b4::29) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|IA0PR10MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: 09b3b919-b7f9-450c-2eb4-08dbc452724a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tuj1ZSp+fOXDW0Iie28CMwlnn9zZCDX9Fsg98dMAjikiJtLjEECsLXCg+jSTMTejk/VSm5AdANV8KEDMMZag9Sum48GoqEhVwjjjLcDKcBYhJdPkYBbpPjE6dk8z+MhX2I4vQzqUQLgry8sJowrUzFT+CgvZ2Ke5Alu0iUQH7/Ja8D3jiLUelm1QUCJd0BYXL9NuX+f+R2Ypp5CCAHvXnYkw8q4DIstBnmPIhv/nO785qy51o1TGlVgJm4z8TNeO5xOozfDREtZjJObj4P2x4Stv/QmOjITPSrdC+ga9BQlnQXph7GSME5VVFaJ1H5mihrOvmzcBHxt1dySJucVa4mDNQfJKD8lFXq/kd/iFpr4g9jsDLkJ8oPUNNfUQZU6gM261KgQcvaxBEd3GdNffv7xih+YHuq7SCil67wxrRn9hcpOhAKYPNTkuHz+oNCOJMPY4Yyi3TSdxEFznOAYHWKf/M3/gI1gijUzp0XaOrKQtYt6LW4/feIpz3/y+rPt+DliukqiPmIlN3nJZYItAQ/x1akXARepWP6A15smr+Yw= 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)(346002)(376002)(39860400002)(396003)(136003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(1076003)(107886003)(41300700001)(6486002)(2616005)(6506007)(316002)(6512007)(66556008)(66476007)(66946007)(8676002)(4326008)(8936002)(5660300002)(26005)(478600001)(6666004)(83380400001)(38100700002)(2906002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Ve3cigjG3wxZ/8p9rteY2Ak6IS69vDOglUdjVnHw8F+6sNn02/bICH/UpUjkiVN624vQ9XPXB9DZQjQMSSppV5ksoB57Y5H2xIiDFs9c0EC8+bO2OmQQZcCwOq2I/xv4So2aFrJRSbaJ34um0XAJu9m/j5Z4dR5Kw0f84t9DpHeZnr1soT3mmqtHJY/B4Ew5ZAb9ChFwQrwNYxUfaVWMUze2V/lHtlG0r/oliyyM94TogeHALTHT1nvRadbUgNHIChnvGnje2eRWBB2LfKyVsH129KvF/y0huydPwm+i70GBndmfEzcZQS9LTSaInbt8lzfvOAe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1VPAcrEYaAc1zylKk830yhL1M62Qv/56FypsZdtR1JzojJqHk4FnNpuoPHYJ8fQqBkMG1M6MjzfFS2yY6nbGtfgvMwwkMFJwaFl7ZPquVuJlt3gDwwMmTuBHpU3I X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09b3b919-b7f9-450c-2eb4-08dbc452724a X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 20:50:58.8009 (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: eqrY1Y1NpiFw2U5C7ST464y/ErEtvUvYo5axFJSFHnX9vVpAem1FlDwZTvcH/+yFBSivPbaQmV1WZU+Qtc8UAi78LuuCgABU81JFKU6ta6E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6794 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_18,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 phishscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310030158 X-Proofpoint-GUID: v-4rcGU90P19iVsfGiTQDymRC5OTGluW X-Proofpoint-ORIG-GUID: v-4rcGU90P19iVsfGiTQDymRC5OTGluW 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: Bart Van Assche Reviewed-by: Martin Wilck --- drivers/scsi/sd.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index c92a317ba547..cc78b5e49f32 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2388,11 +2388,10 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp, the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN, buffer, RC16_LEN, SD_TIMEOUT, sdkp->max_retries, &exec_args); - - if (media_not_present(sdkp, &sshdr)) - return -ENODEV; - if (the_result > 0) { + if (media_not_present(sdkp, &sshdr)) + return -ENODEV; + sense_valid = scsi_sense_valid(&sshdr); if (sense_valid && sshdr.sense_key == ILLEGAL_REQUEST && From patchwork Tue Oct 3 20:50:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 729621 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 60ECBE8FDB7 for ; Tue, 3 Oct 2023 20:51:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232223AbjJCUvS (ORCPT ); Tue, 3 Oct 2023 16:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241082AbjJCUvQ (ORCPT ); Tue, 3 Oct 2023 16:51:16 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70099AD for ; Tue, 3 Oct 2023 13:51:12 -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 393I4n0q014375; Tue, 3 Oct 2023 20:51:04 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=KvmCSuVrrZzXdQLjEMW8wOf600yxbRLxRd0JCSbsAtY=; b=wEcu75Z5IDGxTAFx7xYGsb2xsJymBz954Sx3t5LNHvfCsCB/OoRHcW02adcY3ck+90d9 OdHIiO9Dig0lwCD1jjk7TZaayt4FbJazJXL68WBE7CjL40UcP9hu1vjkzQQGl7AFCbc6 /hfxLHXDz84A2Jyw0QQTcfn6/kEm8M8fNoXkOw3tqovAWiOv3c4uStKXWjRUrKWzEDx6 /a0Y4PC+H+zLw4W97Y7bUdpdccXrDZbfD4BrzFt+Z8jP6UzmKu9BNIBHwRHjO9jQbRcf 6t4Im5u0t6qUMZNUMhF0ELf8K0hYVW7s8QTrN1e6JQgEVylmPZMaEY4Tnon3Ffaro97D 2Q== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tea925ryb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:04 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 393K1ipq003023; Tue, 3 Oct 2023 20:51:02 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2168.outbound.protection.outlook.com [104.47.57.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tea46kv59-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NO/3582Ljw9DWKS0XFjcYYiDq+9nnupL5YzRpo6pnzgj2dDhpSDYni/sunG95DoI5UP98Qt/0PikNRph7bp80oc6ApVkwMildNcBy1WL5queadtu9Q9p9UNoyJU0j2b00+aY6Wmw45zZPIuTMsnbmTOEy3y9z051U5iCmRB60Pvg5rfCxnmsKOOl2xYw/hyCiGsKlxHH1/IkWU+R1HPRCFcia3g347lniVDBoi3QNyrzNw0zP7SK/w5UeET2jylphAfsPFu4U/xCElzifkLif/Y1BPNVR7Qlbaj0ReEPwR4IfNYVzru6C3SWw6F5gPGfyvQSWV+DGyI89nxcJqd27w== 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=KvmCSuVrrZzXdQLjEMW8wOf600yxbRLxRd0JCSbsAtY=; b=ZACAttlJuTDT6wCk2MM40e79ztxq3/cXZZ9RqIQ4wTf6w+AG3THYOLdHsDkzv+Q0N4/jSc5kE/tlPNDrppDuU38jISlQPjUIVgY9dT7dipJ+T7yJQTYYfPSUHyoCR0zR84kRFRHs/4h/T1dybiR2wPvRuVfKukxK+bXQHPhp1dqRQvfjWvG+MTqseGoRG3qaOz7F0cB7//U4Cmx+q51SCLePgr2ucNOrsN/SYK8ga6ShL1LHsD2uMSGhbx4tzvG7UJSqKrX+0YUAVj4qLCCCGXPk3ACiu8FfKNCIYtQdmdbFviwZnaMVyIwvupoiUZJmHgTjmwb7ZoxEBUOgGazoVQ== 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=KvmCSuVrrZzXdQLjEMW8wOf600yxbRLxRd0JCSbsAtY=; b=zaPAZbqcnyeoccQbAGgLReYxMwAoaiMfd4COOkBZGusAPRfqo4ncLbML6adb/4iecLhmq4LLC9w/lUZ2I+A4N5y/JapyQBwBZSdMuqYCDiqxTp4+qKKQIB7Qrpkgnrh9RuM+ZYRNOzIjs7RgiphRzEMLilmlrIkIYdkZvWnkMlQ= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by IA0PR10MB6794.namprd10.prod.outlook.com (2603:10b6:208:43a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 20:51:00 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6838.028; Tue, 3 Oct 2023 20:51:00 +0000 From: Mike Christie To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH 02/12] scsi: sd: Fix sshdr use in sd_spinup_disk Date: Tue, 3 Oct 2023 15:50:44 -0500 Message-Id: <20231003205054.84507-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003205054.84507-1-michael.christie@oracle.com> References: <20231003205054.84507-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR07CA0001.namprd07.prod.outlook.com (2603:10b6:5:3af::10) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|IA0PR10MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: beffaac0-7b6d-46d7-3d07-08dbc4527393 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zKtz8Pho37P+Aab0TV/GU2k0AP2QgBH12G1PQr96lhNBFARZraVZ8flvINm5WH5umPQc2aHIVzmKpsWdSZOyby6lccDHAQhAG+g2kH4gIJA/cYnKMwg9KMmcfX7Lf8L0aBE3dGfdR0PHbkNObY4pFJyNMJAw3DABK2ZMkcIJHgCkP1Ut4aSkbSJlGZ+YO4AmheMk1M9/MDYDSX9LB+N1otTcT8PvHqZMBx5sjydv3VZQkTAYEEvwMjIXxXuqYOLtEDOdzgOkQZVSIC6PDzMHHuKmFLQ/augy/QUlMC+jNnLVcnv55jXm/vP7bAqtooQ1AjtOpn1ZmtbZIpxjMb7DaRrWtrWvqzKxFAP1vVy5R4h9WUp/Anvj3XyCQzhsUbKfOkqvm94O20okNnjszAQEEFoQpYq4EPy6RR4N/Svb0jES+SvCy++Wu6dRACLsw7lRTC7DwZXCLyoo4+5hwN7VnRIbAmI3QIfecNTFdk+p+BT9TY1SNNn+kgvBgH139KjSnID1BRLVdhnQ2C3tSKct2VvO9wUV1tRCgj1JDScUeLP/gf31c5lbhhpCEYJkcbYj 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)(346002)(376002)(39860400002)(396003)(136003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(1076003)(107886003)(41300700001)(6486002)(2616005)(6506007)(316002)(6512007)(66556008)(66476007)(66946007)(8676002)(4326008)(8936002)(5660300002)(26005)(478600001)(6666004)(83380400001)(38100700002)(2906002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gPSB52y4twZ7vryDWrLY962iNYuqa0hEkzZLt9pbqY866+I8APkAWiM9QSFDLukkaP2w7mH7EF7Bvs4/V17QDaO+dugRRutjYpm0VW9GGFQHO25acC4bzuvuhslCa8Jfaz7gVbYKorb5NwcRcCTu2/sDZ4zorQbljZEPa+qpzBccypxEzTSemI7CiOFkhCPtZ2ipDmwpREpZYOO4CO4muV2yEvg2GrJbLKQKVHcoOiJzjPVC5hq4DTy72gSEXS+zRAzlR9mwios2YyOcsDl7/CuDHlzo8n0XaaE73YqYl1QzqqwmDNWwdMsOwZc1oDYpHcsoFUH20F22+FqQL4b7RHhCDml9Rdc/YTXSacAo/MCsJevops31Vjqx2K8l3woDcLtEMz5SfCa+WpWV93fmkVhta3iuF+0rprPZQmdsC5eyPKagFqLOBSIzEG79oU9CwR5gCastpCn/7ovxfG9IS6ITyBPID3zyv/FKBnh2Ttc0zYx3cGyprvEdTM+s+T/fQ6txDyufANQQfee5oDyCwEOYENanJcUDqB35GDOg3OSsi4ZUgBnXufUR0bkbDid9YqMkPRRBqYD741DNkuxvMZAUL+z8WBC82xxg6xp2U06F66VVqELBIEMJiWGcp0W5M6Z02Lye/5hDvHaTAkEY2slKl/klfoJ3mwxrES/rD1FH6qWJLkmuXHG99oRFtmw5L6MP8CM95ZpMjYkUAvw+h0Ukv475F2cwOQxB7MMTrPDhFwTnCJY1z6V8k3bqMqa88nItpZkQClr0iL+oGqls8pLYtTz+AUpAEpklFtaak9JLUzobjlZrDgxst4s+jbCqld7e4D1dZd8S9zNaViNkBOvU9VZzsGjX4x3J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xC0YAr0yMUoJiHFFR+CXIj3t03Fvu9SHlbcgr6EL/7+eBhZ1SQu/LT1GKxGdDYDlrZRZ1hOmb9bAcM9nUNFpXi6MESClB0zOOzuB+LTTr4HUmJQ31BMsCxFBsR+BCh8hYdw7AcW0ZgYGS+qkJ5apeEk1A6k0vMwVm7BmmiHi5QODCZjZaFdZInhBYad9xHaCBtL73KfzsR4eqBtIiPRbgQ5tLUxgSPlGqwdAQqZ4+FicIMIumOIOJr8RqWkbq+r2fYVa3xWnqVrEGWQ7kyJBD9tj1rS9EbrgLpH3WShRAjvLv0eUL3vLeqspBW7x73OJwmIabncTIOfPsKaXHJmVAhsrQdEyoLmZP/LC4yzLJm59YbESQLa4/ImQV9ZQLWehC3FTd0mW13QeIft7Go/hURYMObDrCrxnlCfJNopts38vpFx6EFLRdEBUSeMa7kfTR6pNPPVdT+JXOxUgjhpPr3aTxAg9P3WZQVXvyNiRHP8DE48aVYtrw5WSpavQEzjpUoThXCQeQ+/BJ0wUxsGUpwMkxNg0mkBQJlhlhkb4nh/X55oiFbW7LEzSu8K6GVV4x1DfcUu10ipXXeX76IcsDjgophfP0uyYTuDbH1jKKLSJN9MmDWymprQVU1xqQGB X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: beffaac0-7b6d-46d7-3d07-08dbc4527393 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 20:51:00.9174 (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: TwkKaOHCXbizAGgNnoKhsUbv+Y5WJo1+xU9RXEtfe4CmjSkSZLGfqF2zfDC2Agi5Xm1fS+z2LRlbSxu0/GIXF1XScnrzj2q5wooF2BDAYv0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6794 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_18,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310030158 X-Proofpoint-GUID: sA4d0Nh2CaDYN_mnQbqQR8sH_lrBdmp4 X-Proofpoint-ORIG-GUID: sA4d0Nh2CaDYN_mnQbqQR8sH_lrBdmp4 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: Bart Van Assche Reviewed-by: Martin Wilck --- drivers/scsi/sd.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index cc78b5e49f32..dde9b6707980 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2180,19 +2180,21 @@ sd_spinup_disk(struct scsi_disk *sdkp) sdkp->max_retries, &exec_args); - /* - * If the drive has indicated to us that it - * doesn't have any media in it, don't bother - * with any more polling. - */ - if (media_not_present(sdkp, &sshdr)) { - if (media_was_present) - sd_printk(KERN_NOTICE, sdkp, "Media removed, stopped polling\n"); - return; - } + if (the_result > 0) { + /* + * If the drive has indicated to us that it + * doesn't have any media in it, don't bother + * with any more polling. + */ + if (media_not_present(sdkp, &sshdr)) { + if (media_was_present) + sd_printk(KERN_NOTICE, sdkp, + "Media removed, stopped polling\n"); + return; + } - if (the_result) sense_valid = scsi_sense_valid(&sshdr); + } retries++; } while (retries < 3 && (!scsi_status_is_good(the_result) || From patchwork Tue Oct 3 20:50:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 729619 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 0C464E8FDB6 for ; Tue, 3 Oct 2023 20:53:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241115AbjJCUxV (ORCPT ); Tue, 3 Oct 2023 16:53:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241106AbjJCUxU (ORCPT ); Tue, 3 Oct 2023 16:53:20 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EB96BF for ; Tue, 3 Oct 2023 13:53:17 -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 393I4noT014379; Tue, 3 Oct 2023 20:51:07 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=NOev7xyoovK8ktsV58b4Le1y2SkZuIC477t/WP9J80Y=; b=KjbLmMlk/Cldj4RH8C2+of47y4kjDCf+RjuBarMikhPrziqLzbMsP1AwTIVdmMMYonQo 6OI7HPTCvpd/OBqwrV6L9tLadA8StcA1F1Y+fgZv2zdAc7+cxYXhxd7tMINdCC2LKLD3 MDqX7vzwM8mlteBP6RSr8jB3JUPq3C43SM0jZxnsF2sKhyw8l7urjOa+CoyKBfxQAwbi iCyHwDUcRGqBb9KyO/fYHcTVc0UL7+0lxDz0/rwvUOMltJk+JgUIrQLCHz8RLnCGlbVl n84LsQWa5JavW1a2F8qSBntw42+P5dYeJIhEmRj0wQknrIyvZSRwWv1AcALiOuBVfsTn tQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tea925ryf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:06 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 393K0bYw025731; Tue, 3 Oct 2023 20:51:05 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2172.outbound.protection.outlook.com [104.47.57.172]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tea4d11kv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:05 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QTc3hUdine5sskQmpG/sHMyz3SM8Fort/mJ9iF13ufnjSBMGEPhXJlYZPwFwvFvYR9r7odUomGHTHOJ+da67bK0BsdeDNg8fa7YYElaSxHu1cF/stpQqCfbCBTLMATi71jYOK3AEGCBY/xx8JzApOlaPXtqXgDcV/Pr8N1DX+1eVAEU1LODlHT03b/tYJlPhP2u1JvNXJOksca+Cvc+DjNPA65riotE5Jfjbj5xiAHRm0EusSVEGsJXFitpVc+WiB+fCKC5u8/RkIEgjWC0tSBxsygk2G8tjD5eBKPvOvkU2ac3LB59YyMRZ4oEG5EoNhIQDXF5OTkFiUFv5a1Xk3Q== 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=NOev7xyoovK8ktsV58b4Le1y2SkZuIC477t/WP9J80Y=; b=lZjRmp0fosq2qp0Zyv/Sm57BPORb7Su9e8ukbDZwK77oBEDKjQGh11MhurPR/pukcRx3eExQBd5+KN43+9sVEa0ZRXag1vRsjm5KtdxRVmq1GUooO9wJTLvsT16YOM3Q7Y3uqQvNRic/cBgYFcDBMDbCQVw7i4JJ6NDsgxUxCWfQj3Yo89spmUwU5dQhUFhvZRJT7/xQKqIu1N1sm0HVU99hRPC+i49gzaE7lqZAi+AGqQv3qHSWN+QELjJlK0OqNi/gDBD2Aw7ZkRxjpT1NLD9ZRblKY84X0YP/+0ohA4XDGXmwvYlSD9lb4kZQHLqzLXYQdHL2ibfm8CEHouHq4w== 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=NOev7xyoovK8ktsV58b4Le1y2SkZuIC477t/WP9J80Y=; b=ZWrskCB6RQI9QTDMcrFPJj1ZXkkOMriVzWjlAQhfgJi1d1o8Ld7yxEbssXYhW8Lk+xcmT8saZB6VicyT8c3Avm5qHXxUq/vuLQWxDaek+q1zrsx4zolFiOhlCEpoFZNJhKVVala8rGeg7yPiw0NNXF6DtGdZi8WV+PGR1dlu5tg= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by IA0PR10MB6794.namprd10.prod.outlook.com (2603:10b6:208:43a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 20:51:03 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6838.028; Tue, 3 Oct 2023 20:51:03 +0000 From: Mike Christie To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH 03/12] scsi: hp_sw: Fix sshdr use Date: Tue, 3 Oct 2023 15:50:45 -0500 Message-Id: <20231003205054.84507-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003205054.84507-1-michael.christie@oracle.com> References: <20231003205054.84507-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR17CA0003.namprd17.prod.outlook.com (2603:10b6:5:1b3::16) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|IA0PR10MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: 613b7019-25f4-4a37-9a7b-08dbc45274cb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: daqCkMarzbbiaT6aLSlrcJyw71ZEZDgLX0CIW5upVmtQOO5tTnnCUNZkouCvYTbhMuRSIPeGnc9CZo1gJW0LiNXU+pu8Oxbfqi9vUfScOlQalq4R8tXQt9EKZxa+ipy3y7mPVKJo8KRKdNJLD6xc2X5U+h44VVPPe3Ugo8dS7PaiQ27qIpxIdPyxEa4flDUHrx40tfTzPbbCp1covJBUlgojt1TGyCeSm2uKzDpNIXGqR3IpHrv+8BSFeLaSzle16SL/Im23yK+PeRWJ3k+MR7pyeQ2eB0iJ1tlxQDwx38631Jmp8t3pOgCVkaBK6Z+9UcndG2HQqHzPvKvgYhVsIJewCdB98sDLUGY7WDkJSBkSgcb6paImEJjiUg3uWyaZDVeKmjkGgFxAkfzsBb5HmxIVlS37MTXxJ+BDtjsKN+INUOhhkC3+wo/NMjbnsFDVupG9CDJeZ4CdlxJSQrQP3oPrEo4neTH+VNUz83OmgXNy64zRxhnRuJbuHJ5axdfW1rXq+aeFVo8IL+8x6Hu1aojOHapkYIVcYWDdEj1ugwhNmIcee6aZ+KEPGvPYZMEV 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)(346002)(376002)(39860400002)(396003)(136003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(1076003)(107886003)(41300700001)(6486002)(2616005)(6506007)(316002)(6512007)(66556008)(66476007)(66946007)(8676002)(4326008)(8936002)(5660300002)(26005)(478600001)(6666004)(83380400001)(38100700002)(2906002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MiuUNt3xtVWpbv45Yox2O/Zld+nDg/EMX8fA0FmtM9YbFRlUqkTKgaY6mTLFlta5HhIgay+s0OzExxVYWRO2SlEWUTAyIlr6RMVdvG67kGEn2WAhVU9r/2GDoiz3M0/TpjTgCyHoOuOxaoNQFl4VjUuYhGbu9RPCZIdj0pg2bGVo4KuJlTGO9Ln9/TExhQlFj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LfGXRUw7IEImyoRO+3g2TB1YDp2tz/auVdcn+St6V6F9jwFEqbBwYB+Cs5uDq56MqRJJrR78fZxR0leh9CyZAwT0B7jkrAOMpQQzmWgKTNq1QakhkbpLE9qMCVn7ucxEGvnlm+dWHlExlOScth4F4BYyV6SRqo9Fdbj7B5hd5BJSapqZzLIsAwngidRhMkVXf7+oY+gNsvYPlrmX/UFECLbPNgFE1QwkwMlR2gPVX8DKiDyp2kuxOTUIos6rlFgNe1MkqPF4yiAUfI3aoL5hayFgsG07vHaSyC6OLjqwAa131P+D/hBFlqvbqvvTNhjhvdJc0VhLkHsDMEZIoquow== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: QxjdIa8gSA0G4YAczniy9a0JlkdjVHif5wiMG/PmVF88MujIKcKta1MA3EkJrvYZZg/XbHZraKAyuPHA/aDhoyarX+zk49SfYOcpbzO2Axmh/MYlNdnWL5NQttQM7irPNnzOe5qBclssNhOhWIZhM3lUBHpOfKOyjkHyUgjFOs9tGgA8S4LVrTrkHGcC+XJNCy0eRY2XtoeuaJbLRmF3m7tDRtRauUZBFFZMwGszOGJXdoNLWKiaMbadvsrT/R1Q6LGna7ZAIspDPB07DrDTRU91KUyESV4TnoLOPsrb/AKej0+Yy/XsRs8zqV5StUPh6VU/WgTwaqvailCBKTt1sMHEb1JSydI3qcSqdcNlh9vm9OEmecB7xNsAgrD8ZEOb1vuI5+bv16dFoWoEmDQG+MYcDBeQG4rxwqclaz3uHRmz2piAlpMEf8AR4j/U5yNVr1MVsGtJwPS5JdBAOSQ2RbP5NrVHXnJSURtZXuHMQ/iM2hCoAI3FJW62efF0odT4qU7WbH/PKm5ehFh6FzBej0AhjF/G9L78KrnC468SRpzzYNtSu08reC8ruFynATG8OGws8A3fAxXo0mynGBiNIs+AUCM05icuf3NDGlO03Wmq8qTne2K1FLWze7t0tys96IUJNeyydvTf7P8X8Wks5aQPUa59SsXVDP3WXsTGwcW5370SDHlKKfuw+e7Vz7zNw3WNmIEkA9eYi1YrZv3+Tc7fW+aG63ccREN4AFYHmmVAaI0cbUHylYWq2P9vM1CTubBy4pwx15THPiefVAtC8jk89nKCc8B87S4Lo9UrYTCZTyM90xnFQmKt9+PnTPlCDbkYufGh2s/zaxwTORkmIhDr+o3QE9/I7Mw9mi2nWp8YaThyj4p8uHyynbrdqcC9 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 613b7019-25f4-4a37-9a7b-08dbc45274cb X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 20:51:03.0270 (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: 0HLnMDhqHNHyJiGW+W6oVlzaNTUumJ84lSlo+C9AGjin617ftKd8PYIFoTjdoDpYxtD5XPSyByvybkv1pmR3jt2KGZnOuRpHe/Ea+ivg4xI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6794 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_18,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 bulkscore=0 spamscore=0 mlxscore=0 malwarescore=0 phishscore=0 adultscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310030158 X-Proofpoint-GUID: 7F9ENLAdQPTNzmTs4CdDbcCPB4x21ov0 X-Proofpoint-ORIG-GUID: 7F9ENLAdQPTNzmTs4CdDbcCPB4x21ov0 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/device_handler/scsi_dh_hp_sw.c | 79 +++++++++++---------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_hp_sw.c b/drivers/scsi/device_handler/scsi_dh_hp_sw.c index 5f2f943d926c..944ea4e0cc45 100644 --- a/drivers/scsi/device_handler/scsi_dh_hp_sw.c +++ b/drivers/scsi/device_handler/scsi_dh_hp_sw.c @@ -82,7 +82,7 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h) { unsigned char cmd[6] = { TEST_UNIT_READY }; struct scsi_sense_hdr sshdr; - int ret = SCSI_DH_OK, res; + int ret, res; blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; const struct scsi_exec_args exec_args = { @@ -92,19 +92,18 @@ static int hp_sw_tur(struct scsi_device *sdev, struct hp_sw_dh_data *h) retry: res = scsi_execute_cmd(sdev, cmd, opf, NULL, 0, HP_SW_TIMEOUT, HP_SW_RETRIES, &exec_args); - if (res) { - if (scsi_sense_valid(&sshdr)) - ret = tur_done(sdev, h, &sshdr); - else { - sdev_printk(KERN_WARNING, sdev, - "%s: sending tur failed with %x\n", - HP_SW_NAME, res); - ret = SCSI_DH_IO; - } - } else { + if (res > 0 && scsi_sense_valid(&sshdr)) { + ret = tur_done(sdev, h, &sshdr); + } else if (res == 0) { h->path_state = HP_SW_PATH_ACTIVE; ret = SCSI_DH_OK; + } else { + sdev_printk(KERN_WARNING, sdev, + "%s: sending tur failed with %x\n", + HP_SW_NAME, res); + ret = SCSI_DH_IO; } + if (ret == SCSI_DH_IMM_RETRY) goto retry; @@ -122,7 +121,7 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h) unsigned char cmd[6] = { START_STOP, 0, 0, 0, 1, 0 }; struct scsi_sense_hdr sshdr; struct scsi_device *sdev = h->sdev; - int res, rc = SCSI_DH_OK; + int res, rc; int retry_cnt = HP_SW_RETRIES; blk_opf_t opf = REQ_OP_DRV_IN | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER; @@ -133,35 +132,37 @@ static int hp_sw_start_stop(struct hp_sw_dh_data *h) retry: res = scsi_execute_cmd(sdev, cmd, opf, NULL, 0, HP_SW_TIMEOUT, HP_SW_RETRIES, &exec_args); - if (res) { - if (!scsi_sense_valid(&sshdr)) { - sdev_printk(KERN_WARNING, sdev, - "%s: sending start_stop_unit failed, " - "no sense available\n", HP_SW_NAME); - return SCSI_DH_IO; - } - switch (sshdr.sense_key) { - case NOT_READY: - if (sshdr.asc == 0x04 && sshdr.ascq == 3) { - /* - * LUN not ready - manual intervention required - * - * Switch-over in progress, retry. - */ - if (--retry_cnt) - goto retry; - rc = SCSI_DH_RETRY; - break; - } - fallthrough; - default: - sdev_printk(KERN_WARNING, sdev, - "%s: sending start_stop_unit failed, " - "sense %x/%x/%x\n", HP_SW_NAME, - sshdr.sense_key, sshdr.asc, sshdr.ascq); - rc = SCSI_DH_IO; + if (!res) { + return SCSI_DH_OK; + } else if (res < 0 || !scsi_sense_valid(&sshdr)) { + sdev_printk(KERN_WARNING, sdev, + "%s: sending start_stop_unit failed, " + "no sense available\n", HP_SW_NAME); + return SCSI_DH_IO; + } + + switch (sshdr.sense_key) { + case NOT_READY: + if (sshdr.asc == 0x04 && sshdr.ascq == 3) { + /* + * LUN not ready - manual intervention required + * + * Switch-over in progress, retry. + */ + if (--retry_cnt) + goto retry; + rc = SCSI_DH_RETRY; + break; } + fallthrough; + default: + sdev_printk(KERN_WARNING, sdev, + "%s: sending start_stop_unit failed, " + "sense %x/%x/%x\n", HP_SW_NAME, + sshdr.sense_key, sshdr.asc, sshdr.ascq); + rc = SCSI_DH_IO; } + return rc; } From patchwork Tue Oct 3 20:50:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 729201 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 E5CADE8FDB3 for ; Tue, 3 Oct 2023 20:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241106AbjJCUxW (ORCPT ); Tue, 3 Oct 2023 16:53:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241109AbjJCUxU (ORCPT ); Tue, 3 Oct 2023 16:53:20 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9114BAD for ; Tue, 3 Oct 2023 13:53:17 -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 393I4onC014413; Tue, 3 Oct 2023 20:51:09 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=Bvd9OZQXP4ZTfBe+ZucwdWwUHzLu51vzP7zdoAxaO8c=; b=kePzO9t7pBK8gowx9FmvoLfiDKVPkkasdwlP7cAnw9nJktRbbDAY2sOpUOM6bH2RjGHK o4DiV/B172EAGb3mLDxo645ke1vTQMsxWJuYDqf3cUsdNnQ5eIJRoA1ZWBsucL1wfaTH vM3wYOkQGXhG6nf6V9n+UgGXoJRjPWw1M2n6RxVQ/3FE+0q4AuJW1fZCTjkuA6O48VMb //KILBiVFM7bvAe9Uy3qXSDOHT85s1586k9IPc7zzhWTNJCmn1TzJeqw4iU+8LEgqN/I XnrxTRimRKtG3ccVU3O6tlIhm+bbxBUyNriTK7njawrEG9MhqZV2hDd0a9y/i1aNhi/w PA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tea925ryh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:09 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 393K75f6000467; Tue, 3 Oct 2023 20:51:07 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tea46j5fp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U8cOD8aaqZr3ts80DZuOLivlrAbKgUaU1Mv7hr2UuJ5z5/aBucMbVuTgyp9s2LiY9oTwA0Cy+l4sxGli/p6ASSQa3pldtzY+WmCPj4t2QULhls924GqloLR2VAiYdVR6rtQ8J3nmXiAsyC2OnjzfifDuSZpjmEo1SySc1LeaPRfHim90cdkK56TzLpVAnP/NpKFk7UziVqIzr6OjhY1b0zKvNB5jeO2DgoafieajFgHO32PVi+SY1O559LrfazdCh3d11eQpctUxbcpmLopgxG0I/wPyAmwLOcRLhWiVIMviu83RC7j42MYOl109xZBA72hcSNHtwOKJ7PLu0aajKg== 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=Bvd9OZQXP4ZTfBe+ZucwdWwUHzLu51vzP7zdoAxaO8c=; b=oUHQWBJQrqetpD04QotOjD7iaOmo76tmGiYDBMs7gLvPP901+XqcRsYFzyFQc96p0FeqargOftH15QLLxbWcYw2nAhSn5zjXdrF6BZLF08Zdcl0fQtCOwJbUVSLRCf/2CI99G+2BY1ps49Y21sjraFxH7YBK540B4WnTnPffgkFx2iCPhC/HCjJ1BXqw3DTFrGrjPsCOxYYjwMB1dWSEl4Ow454ZVpR9O/y0dJ7aYD5F16Fz0dmr9Hrg5wAiUrXzWGY/rgEw5xBDW3cFRI/suzz7vXqgnFiQaxHzBsRXWfF0iLGjoHKiggU2aeZz2GWOOdwTnyHn6PSdr3Ycnx87ag== 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=Bvd9OZQXP4ZTfBe+ZucwdWwUHzLu51vzP7zdoAxaO8c=; b=NkW5r1uw0ntlE2BNLU4tAlU+8TSY8fX9VgYC7cEZ17Kkgf2yp7bXuMMt4O9JG2XNnQUe+NCHTcwiBJfQoUDlVTbJTrd0wsLxC3P7GVOu2ZmGweWnI6zClDRBaltAVZe8fNL53Ghtf+e0jQcXKz6mkApIYyJ8RydZX4lTuwti/0s= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by IA0PR10MB6794.namprd10.prod.outlook.com (2603:10b6:208:43a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 20:51:05 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6838.028; Tue, 3 Oct 2023 20:51:05 +0000 From: Mike Christie To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH 04/12] scsi: rdac: Fix send_mode_select retry handling Date: Tue, 3 Oct 2023 15:50:46 -0500 Message-Id: <20231003205054.84507-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003205054.84507-1-michael.christie@oracle.com> References: <20231003205054.84507-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR17CA0024.namprd17.prod.outlook.com (2603:10b6:5:1b3::37) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|IA0PR10MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: 7f17ad7c-7996-4f9c-6d30-08dbc4527638 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yAyfWWxubyCHE7vNqKqLdN2XEnHTGvh71bfTu01riJHfi8kGFWFnWEPLgUe5gBZo47kf1Gj3qT/NLKG8JDXuyejQ3LPiVzTDQ233BcnVPHmI7a4B7c2vK6md/+jDveualB/kMI02srXgRlTPpfMf3SyX310qIGCxQlwkozZ725jKPZ5J6TbEiS6+00YBbht6Sx5SWPlFOkC4t6GD73iSZORGwZfqtoxo57qe5ZfZkzmZOY1lCbi1a9VW1AatFN23U1+v4SIkCUPYxuCmmmqpP4DOP8L12ew1wAQuhV6uUhEEaAByOSk4fT5V6MkgmRTMhka6s4XrDjJkZtM5VHS03Q9NNCR3ZEVoN6HKxYO8bIKdmoKEd4KvMVneyDYOVQ5WlxvVgaBfovjl16uGhsp+qfGkIsTMD/CrMaDqH5XUcxzx4qAtBd5EO0NbdyUNy/Ggddv3Q+givBx0/DdmSrJA99lfl32xoWdVj+Wrz4JC5PnvgOR+WD2mj9T8eoP/kqaEd0G2WMoxafMoo0PX+YwWDAr0c+2I1DZiwlG81zQthlSlTZP2+I+NA7t5m/3Qza7i 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)(346002)(376002)(39860400002)(396003)(136003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(1076003)(107886003)(41300700001)(6486002)(2616005)(6506007)(316002)(6512007)(66556008)(66476007)(66946007)(8676002)(4326008)(8936002)(5660300002)(26005)(478600001)(6666004)(83380400001)(38100700002)(2906002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ChWa3yEqSHK/IyoCi2iEteOaVViJQ53BAGkNVpCI4RSmwbfBXqYHFOd7+s846IlTRzcnQkQMJsztEpb9rE0Ef9AFkvjnjeQTqzVxvQgVciJV4H96nB6on6ZCKjdpeMV0VCT+5yl/HMpZYiur+RhRYgXkzxfTpImZSJItGD7ijF+gzGOyEjOVbnPGp51P3VFW/kVLCrSaLZ7tjpDgs7KIfDTipl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pZSCn6yFq3BN9uYU9q/DH6D32at6ZhSPYJX9Pnn+6yisB3Vx4373B6/BXDlBQrztU98XaUWOF2BBj1f7UvjkGrWAPcEnWTrK81kQXTPTPc3EcYGGWHcVyBRUsRxnVFpwcAvs8XYdhVuX/a5VItzjG74kYI18ck5RYP6m8ijXLw65ZP8I5I596UMTbgxxthXhr6O1QMuupjUiy5WD3m7SgbtrPvF2W0 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7f17ad7c-7996-4f9c-6d30-08dbc4527638 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 20:51:05.4291 (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: 0NYIFohe8ZkoyHa/RbD3OrDuAuSQEADISiSMZkxNmh9SzWu1Sfk1lmVEVymb8PaxjVcYTkFlVtH+c7DqprTdfBS8xQFeZGTuXd5kC+Zgdsw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6794 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_18,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310030158 X-Proofpoint-GUID: 1lObZ7Os3iRzgbiMNWTGr8ruqWlF44qr X-Proofpoint-ORIG-GUID: 1lObZ7Os3iRzgbiMNWTGr8ruqWlF44qr Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org If send_mode_select retries scsi_execute_cmd it will leave err set to SCSI_DH_RETRY/SCSI_DH_IMM_RETRY. If on the retry, the command is successful, then SCSI_DH_RETRY/SCSI_DH_IMM_RETRY will be returned to the scsi_dh activation caller. On the retry, we will then detect the previous MODE SELECT had worked, and so we will return success. This patch has us return the correct return value, so we can avoid the extra scsi_dh activation call and to avoid failures if the caller had hit its activation retry limit and does not end up retrying. Signed-off-by: Mike Christie Reviewed-by: Martin Wilck --- drivers/scsi/device_handler/scsi_dh_rdac.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index c5538645057a..b65586d6649c 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -530,7 +530,7 @@ static void send_mode_select(struct work_struct *work) container_of(work, struct rdac_controller, ms_work); struct scsi_device *sdev = ctlr->ms_sdev; struct rdac_dh_data *h = sdev->handler_data; - int err = SCSI_DH_OK, retry_cnt = RDAC_RETRY_COUNT; + int err, retry_cnt = RDAC_RETRY_COUNT; struct rdac_queue_data *tmp, *qdata; LIST_HEAD(list); unsigned char cdb[MAX_COMMAND_SIZE]; @@ -558,20 +558,20 @@ static void send_mode_select(struct work_struct *work) (char *) h->ctlr->array_name, h->ctlr->index, (retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying"); - if (scsi_execute_cmd(sdev, cdb, opf, &h->ctlr->mode_select, data_size, - RDAC_TIMEOUT * HZ, RDAC_RETRIES, &exec_args)) { + if (!scsi_execute_cmd(sdev, cdb, opf, &h->ctlr->mode_select, data_size, + RDAC_TIMEOUT * HZ, RDAC_RETRIES, &exec_args)) { + h->state = RDAC_STATE_ACTIVE; + RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, " + "MODE_SELECT completed", + (char *) h->ctlr->array_name, h->ctlr->index); + err = SCSI_DH_OK; + } else { err = mode_select_handle_sense(sdev, &sshdr); if (err == SCSI_DH_RETRY && retry_cnt--) goto retry; if (err == SCSI_DH_IMM_RETRY) goto retry; } - if (err == SCSI_DH_OK) { - h->state = RDAC_STATE_ACTIVE; - RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, " - "MODE_SELECT completed", - (char *) h->ctlr->array_name, h->ctlr->index); - } list_for_each_entry_safe(qdata, tmp, &list, entry) { list_del(&qdata->entry); From patchwork Tue Oct 3 20:50:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 729618 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 5CD38E8FDB3 for ; Tue, 3 Oct 2023 20:53:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241118AbjJCUx1 (ORCPT ); Tue, 3 Oct 2023 16:53:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241125AbjJCUxY (ORCPT ); Tue, 3 Oct 2023 16:53:24 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62134DA for ; Tue, 3 Oct 2023 13:53:21 -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 393I56fV006336; Tue, 3 Oct 2023 20:51:13 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=GlTbko+4an/EbVgofn2WGWqLaTtQFO/MiJUZDfDTzhw=; b=fv6cvQTOHqxYdZUyJ3RY0fnF+hSg4N1jyESrx0J/4xcYiUV9LESQLS1NJPjhGpIE/4UY pHSBYe0iO1dILjYV94x4lBc4iDO9hV18oNf5bYzoQMNxvd05GxkTmHBOZR8gXXlRce4Y Ow5iOnWOeiYJZwLBcVTpV/ODgnhLozbfl5hNfcZ73XPfz6EB8b4j4c2txfvHyqFE2+Sv rpu0KWp2LAOQQr8CCP0OvF1nyG1VSpyy1z3KvC14YGEtQjh8LGzDWP2roHZtLmaAwHrX jEhWkzaGC9OG8xox43bofaCIaaoZ8fA4befeLZ+JI34T+8kRCpbhXoc+ULlJoXDMbJLd vw== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tec7vdnr6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:13 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 393JXwR5002947; Tue, 3 Oct 2023 20:51:12 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tea46kvc7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BCVsdUWyZcbZJb67a4Gc90m5yAn8ZZYbu87Jr3OblF97597nGPJq6lc3JJPekIladKZlt4DyW03THN05jnd451QcnoL+4bOeNfzUqSQTiAH0taqxLwFESNMQxd+JqaAnJySAILJweMO2HzVMopkXUAT8/X4CN0RTsCi8zWkaviIagXCRqt4rjWKRpV5SY3Oik/fyWVRRXg4GZvUJjJ7+bHp0WTJV5qi2rhWLiBlQg6HwWRTjQUQ3JHH0mci/XijE5x5lThircwIHfR2irbuvfzOZVXlpiU1nmiq32e6JQ9OTQI25W41YR8vr9nRXpxXNOBafDnjOqrJC+qalMOnVjQ== 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=GlTbko+4an/EbVgofn2WGWqLaTtQFO/MiJUZDfDTzhw=; b=B5Ak4sxM1pWcMwj42PsVu+jxfSgd/OcSPXACdXAvvUUEP7TV2UNXtfOpd19FUCoH/KlVcHc8VumSqMpz+98UTJx26dhhGGE9hECaZyOJ/5aRE91BstTaFWWfLmbh1qrNAP7p0FffpzCM5dRE3TTSgwZkasGyNXieNtUtMvuuOPJykxOtDgGc1WVosGS44LMFsf9/LQ1fSCJwXNXXGKWJbi2tzFJSa0OuJD9APzkFeoArj5BorjixU8xPPitBTkrrErYTX5QbJyrcHoPdk8UPnntL1uYWnHALrykEDrRr9LllFXfoz9THBHnkk0f8ux61AEjaDo1/fTAENOxcgOboAQ== 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=GlTbko+4an/EbVgofn2WGWqLaTtQFO/MiJUZDfDTzhw=; b=Ray8Pac6wDeREiFlfz26Rm1j+gvHB944Wkghrr/g1sCi8NJFGG/qO18l8y+6uiJXtjM6zfEaR9+NWL16taksvOL+WWSc+RgN7UGXurDIlFq7+j8Yidun6XV7S+Og8almv5nQjv7lrHdh0DE3efq8pJsf7si0z28j85IfMIpn1oM= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by IA0PR10MB6794.namprd10.prod.outlook.com (2603:10b6:208:43a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 20:51:07 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6838.028; Tue, 3 Oct 2023 20:51:07 +0000 From: Mike Christie To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH 05/12] scsi: rdac: Fix sshdr use Date: Tue, 3 Oct 2023 15:50:47 -0500 Message-Id: <20231003205054.84507-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003205054.84507-1-michael.christie@oracle.com> References: <20231003205054.84507-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR07CA0006.namprd07.prod.outlook.com (2603:10b6:5:3af::16) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|IA0PR10MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: 0a7abc1e-58dc-43d4-dd80-08dbc45277a2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: N8hspxAGlm0lDvTnpuyTsYF3V/upYsSn4PGpvYQq7g6LVEIjgoLUv75cnb+gfm2UdXh+7MiOGuryJ8d38DaFTSS69w5uz7NA4oiDRm0KLrxQPga1jeON+9iHcLkiY+trOLJ8hGXkI+IpiQtEI9I7SqHHlfKzAXWvFgaIeE3sCgITffNRZdk+MMhZlUbnXEPLkhmgXH/ZwxKUTaX2H0fEyqafjYw6Ddk5kbJjBTOFjZbc6umPYDi4FZTbM23RGwxUmcodxBH3ymHqYOmyl0QqPw1bI8GOpl7tnb/WrTsO4/0NPlJqo3FrBCUOpxZsUPUt0JWuOT2xdhGHoEZS4St0oKkJ+dZojtACSewmBZH6gLNenw7u0HNjyqGUjsfHNj+Axb4DUtbwdFkki2QxYJVuR1aG/nG6aQM/+QiL7G43wURd0U1yXfb8m3riTMpMN3w4pvqBlU12rbpEaqmgCjDWayTA8PVXB+Feb2Atr9HDhCXhBogBXuMkeRwvVPPcuu8vneukvxAoHcq2E+ize2epZdo4e7pR9WGYfeW1o6gfXtiVs0LLjx1JdCEBZfWpoqaP 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)(346002)(376002)(39860400002)(396003)(136003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(1076003)(107886003)(41300700001)(6486002)(2616005)(6506007)(316002)(6512007)(66556008)(66476007)(66946007)(8676002)(4326008)(8936002)(5660300002)(26005)(478600001)(6666004)(83380400001)(38100700002)(2906002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Tc2LpSeMakVLJvsI5MeCha5GbyhLm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TckKv3VJyZgedpz+2+SvVEDo+J+Uhlr3Ha8QuUu25XVglG6RHX3GtgcV0mtEp7/lZG03ley6nP4mEGvvqSned3hoQ7ZpEzL7UjMwKKBuuHKMZCHO9G7qe5SemczXIaKPByH5Mgf0wrY+MWY0iWsD6+Lr3CEsZfDRrQMnSADMjUrXbga5yZBLeV2XtD67M6/7jO0kKzvPXfLRvuCdsy+jt5wkRPmlhgLFBM6+jYQzBm2NFNQld/jzUp6Q54Q2ehbJUFNGvtsHMKlI4dcFZGqLP19JAbMgZQ9spQo/IkT6q+XRDlhA4qJklIqzdAvOVFyHw8yCfgnhBQ8tLkXeF0/L2FqpgefUAYv4He5BoIOAWLg75erx0WltflRYYCKCGs9oHTcB4xSDXKPSt898uW X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0a7abc1e-58dc-43d4-dd80-08dbc45277a2 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 20:51:07.7612 (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: CuxpzIcirX/puPYB8p0ZFTKKGkWPH3WQ7FAi5JIVbaF+B4Ldhy6mPkzz4s4sQ15l+gCUZ9CDW1wH4Jc7P7ij4PatIqsvnwaVRLthGaRWUqY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6794 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_18,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310030158 X-Proofpoint-ORIG-GUID: _kVUE622PCKgrsb2EpIIbrOn7-fffJdy X-Proofpoint-GUID: _kVUE622PCKgrsb2EpIIbrOn7-fffJdy 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: Martin Wilck --- drivers/scsi/device_handler/scsi_dh_rdac.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/device_handler/scsi_dh_rdac.c b/drivers/scsi/device_handler/scsi_dh_rdac.c index b65586d6649c..1ac2ae17e8be 100644 --- a/drivers/scsi/device_handler/scsi_dh_rdac.c +++ b/drivers/scsi/device_handler/scsi_dh_rdac.c @@ -530,7 +530,7 @@ static void send_mode_select(struct work_struct *work) container_of(work, struct rdac_controller, ms_work); struct scsi_device *sdev = ctlr->ms_sdev; struct rdac_dh_data *h = sdev->handler_data; - int err, retry_cnt = RDAC_RETRY_COUNT; + int rc, err, retry_cnt = RDAC_RETRY_COUNT; struct rdac_queue_data *tmp, *qdata; LIST_HEAD(list); unsigned char cdb[MAX_COMMAND_SIZE]; @@ -558,13 +558,16 @@ static void send_mode_select(struct work_struct *work) (char *) h->ctlr->array_name, h->ctlr->index, (retry_cnt == RDAC_RETRY_COUNT) ? "queueing" : "retrying"); - if (!scsi_execute_cmd(sdev, cdb, opf, &h->ctlr->mode_select, data_size, - RDAC_TIMEOUT * HZ, RDAC_RETRIES, &exec_args)) { + rc = scsi_execute_cmd(sdev, cdb, opf, &h->ctlr->mode_select, data_size, + RDAC_TIMEOUT * HZ, RDAC_RETRIES, &exec_args); + if (!rc) { h->state = RDAC_STATE_ACTIVE; RDAC_LOG(RDAC_LOG_FAILOVER, sdev, "array %s, ctlr %d, " "MODE_SELECT completed", (char *) h->ctlr->array_name, h->ctlr->index); err = SCSI_DH_OK; + } else if (rc < 0) { + err = SCSI_DH_IO; } else { err = mode_select_handle_sense(sdev, &sshdr); if (err == SCSI_DH_RETRY && retry_cnt--) From patchwork Tue Oct 3 20:50:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 729199 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 3F018E8FDB3 for ; Tue, 3 Oct 2023 20:53:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241128AbjJCUxe (ORCPT ); Tue, 3 Oct 2023 16:53:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58104 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241122AbjJCUx2 (ORCPT ); Tue, 3 Oct 2023 16:53:28 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 40589B7 for ; Tue, 3 Oct 2023 13:53:24 -0700 (PDT) Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 393I4erQ008524; Tue, 3 Oct 2023 20:51:14 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=hpp3dor4hFf3OVHRK914BNwKq2IFLAkhr3N+zRMQRoM=; b=tj7yJFXOo5Pf4KmEcDIBtUhLuWl+gIBwrplt+lTLGvXolfKgzFI+gU9vsvrE3oDpuNHF WtTpRfmgBjVTWvqz08JUvCxuEC9qzMnsA1hPYdSiZq7ENpScowTDxPTuT9KoM4UtZ4Gt 6s0yEeUpopI9quq+9ef0AWn1QJbVA3q80Ny52SERXrmg7ID1BlWKy3YgvlVQSs4WY+/n ui76+XUvow/PrmncBr/M4FlFtMZtgWWaDQjzYp2sdO5m2TnGxJAe0aXBKxZetdeKJpJG gjuOBXRLW0WkCvqXAQypc4hybf9O/OCMhFg5WWDwt5iNe4wJAKksuSw7HQi40dtYz8Tg cQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3teakcdsdb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:14 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 393JXwR6002947; Tue, 3 Oct 2023 20:51:12 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tea46kvc7-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PVEtu4HefEHVI/89zaU9s6umD7hpIIsVjGhM/Y5+1FmkwrnM7tAM/jOOGDE3J3WxhtWF3qj0R2WPyl4QpTZwZfs4K3lG/dvwpRoUnCOL5RH7ObQh986YMD/uqNDQtbCHn5dvoqMa3pkXgqmJqupk7ReI3FX8NIoDCmTAuDWtD3ZwYrCjfAQSH0H/U6VQI1QbNppVZeQZkS46rzQ2wC6kQA9WpAmgLKxh10RdcGtA3ZyR9YQRQ17v0HXVuMXUAZPP0KSHh/1PYKfi/dGMuQAaVn3OvNqiWbgXKMNWzGWYQhBo6Wye7PQ7f0DDIsqc263usShvyMwomMU3mCeU8Fj4tg== 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=hpp3dor4hFf3OVHRK914BNwKq2IFLAkhr3N+zRMQRoM=; b=JPnwzpPnklQTR17lATp844+AKZnRgChBAIQ1jT3rpI8PLsNo7xMEILGIX1wj4nqGqzqsveE/j/H5DklyG79dhSw7TBowI3HyUipMYHfi1U7016Ew8ZgPcDwtNNq+xLgguabTyAEmJzUGuRQggdGMrCXkt19OM8HNqdWNgSNPH6vlhGho3Ee7HpI0DHW2CUZ/5lHdh1z49q7mnPMYCQe2MCwvVsrLWzj0IfuzEC85TwUpNGeFRJpc0h/i32hlxQKo5Qcvjo9pt791O7nvoAm77e2i9gtlNXNVV3QbwMKI4Ab4GdhW9GRL93JNXVu/f3SOo51cQK4r7dajzPUKh6wADQ== 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=hpp3dor4hFf3OVHRK914BNwKq2IFLAkhr3N+zRMQRoM=; b=FEtizYLY3ZJeKDyOEAPgE4i2iNs3g2qKglHn2wbZlGm2NFCkwkZHU362aBZg7EJyvaIrFvH4ZIJYvWU9/KFIwDTVPb7d+Oy2UEGwOL3A6dedSx0tYTsSq9Ub9Q4a4z9DyvWnAOZLSdKS8J4ACm/ib9n1sRxLaSrCFU4FlmyCFK0= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by IA0PR10MB6794.namprd10.prod.outlook.com (2603:10b6:208:43a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 20:51:10 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6838.028; Tue, 3 Oct 2023 20:51:10 +0000 From: Mike Christie To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH 06/12] scsi: spi: Fix sshdr use Date: Tue, 3 Oct 2023 15:50:48 -0500 Message-Id: <20231003205054.84507-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003205054.84507-1-michael.christie@oracle.com> References: <20231003205054.84507-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR07CA0061.namprd07.prod.outlook.com (2603:10b6:4:ad::26) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|IA0PR10MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: 701cd65b-e0d3-4d2c-7519-08dbc4527914 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RXupx+GaetbI25V8ontJ6CMqEN7+e0weQpwMr3eOGw00ctEJk0ROmW8Q75kiUt6PE5Eury7zNkdnYWuij1RCZFcNfaqwJhHLaaJX7lJOXstHdX7wUkx73rJjcN3NjxLSgdcRoI0uXmi2HNwly4VwPKGn/bpP7DeiKQFjn+WRnraFnv/GKtDLTqhEAZoYXSLAaUCMhCFaweiBSpVSeY3cpsc7qd7AcsrmVcvQIQH9ccytVL/dbuvBy8vXXjqY+PhPM/kPHoXP+ZpIo4nkMjAEZTJnogaBqZ/ie9JN9IlxBbZo9U8pAdJQKWj5jI7/JXptLX6SQNzIzFXGEqOOq7Roqn6/O71kT6CYZwZ/v9BF796j90/h+WCWLhrztqMgct0bbed9lJC9Ii8gQuiU0MXUHLU1fn7VD7l771tPhuIab1a53VGZUntwsNTXR8dDmZrz/c2B5Ab5l5ZU3q5LaYXkzFUi8WGt8N4H4C7ZKY7yR/PyekJpk6lHHGH4SUW9SxL1ffd8YCXVOHOfcvq0KlK+ZmkUqhJqfzrR0+yi1k7jBmDUPR2Hxko8BFl3lHDb9K1L 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)(346002)(376002)(39860400002)(396003)(136003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(1076003)(107886003)(41300700001)(6486002)(2616005)(6506007)(316002)(6512007)(66556008)(66476007)(66946007)(8676002)(4326008)(8936002)(5660300002)(26005)(478600001)(6666004)(83380400001)(38100700002)(2906002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: +AvpmeFnKR0Ox+/1Xi7vG8qXo9NrBoG89gp8wFaQd+sTh8i1uESdyb6Bi63ATdNhZHNbYbmzFtoJOkuA5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p/Ob9bg7+zLjO1+HWhRCg+YGAbKvGogQrre65JCrlRsp0Gdcq0/YPHkLD+dggmejRwlaeKK0IxJt4UNHzUQkLkUe3ejw4PKyjLtRpn/Z6xwvPiNVWk/2JxqPh597sq0hGjzKDmZbmqvTuErJ+U3HEN/gNUP0JldpqwPP+KTtNfHmbU1TTaIC5IYl59GRGKLtTVeoFAR0nZAygVmfXDYTVJwUiWa+nQzLHMocG4b8bC9FvyT9Hh3M58e4pnqbltG+h82UWYBo4wx4UQoMHw/QHvdJmWox4QcOx8FDyb7WdIGj3K4NIWr3s+Mb8roeX0ohjEH/OkfSu1Pfi0dnMpKoxD3QXxeBzQUTnpjv X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 701cd65b-e0d3-4d2c-7519-08dbc4527914 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 20:51:10.1453 (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: JfEoAiIpsNxNCLaW30exq+yzhG21vkEwHL/okrDRLzxNyw++sAZ9BTi+b7d+72O2tzNK2EUjQ0Ek9Y9I3NE/bHene7ohTZe6up8nhHw05J4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6794 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_18,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310030158 X-Proofpoint-GUID: KDorgqw4d5-S-6PnVCh-PASG1RdlhFwq X-Proofpoint-ORIG-GUID: KDorgqw4d5-S-6PnVCh-PASG1RdlhFwq 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_transport_spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 2442d4d2e3f3..f668c1c0a98f 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -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) From patchwork Tue Oct 3 20:50:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 729617 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 8BF46E8FDB7 for ; Tue, 3 Oct 2023 20:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241119AbjJCUxe (ORCPT ); Tue, 3 Oct 2023 16:53:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241124AbjJCUx2 (ORCPT ); Tue, 3 Oct 2023 16:53:28 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1FFEB4 for ; Tue, 3 Oct 2023 13:53:23 -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 393I56n6006412; Tue, 3 Oct 2023 20:51:15 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=DUefhzkjjEiO7/wVr6NH59dW8g/A4Tkn7dXnRQf3M5U=; b=4K3cCGwU9S/DDIcN6Ww5k3mt0kswYT1KtlWpa0sdq83ua7ylAdZySPF8csvY9HbBn42e aDHyLG6rIgzeaKmMMivAreNRtURi/VQ+FvDwKKSw4fXFOvsAD4vThMXjF8HbXOeX3VPJ GYgzK/FlydskZxhR5zHnrvNqHEi//OXjZlGVVvkiI/bvGFLYIi6r8l2ZzN02X0CdET44 g5chgWRecPv8EpFfbkY4kOe4opk1lwra3FRNqfAFtQfWh/0+CGcMVxDzqhwdL0Ws5qfo ybZFKlCISj5yqGYLLUMds/2f1VsPtwTq7qEXmscB6OSch73xC4/qUq5cqrZ041lXqpwk +Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tec7vdnrb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:15 +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 393K3kO2033640; Tue, 3 Oct 2023 20:51:14 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tea46tekh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gtufo2Po/V+hKLUxZhuzmOdKYSzWPtXk/lAGjIRYXpDa+pJE4Ni3WhpxeiULjjd/BB9z/o+/Ol15DrC5Yrc+R9zsby6mqnZq/0HgcAbVZ2pPk0u46QKRP6KvpIgRzSJzFC1abcvkYllTiERug3vsqpXHuu3bBstuKWY/mGAffCBe3nfcjN7YmZn4CnSdYQLuqtdCWkHabUmvKGdfOgfeXaWpu0p3hB6lo8uWdUP1O/5BSfYbTygWN1NxwCdyOnrBX5iePsPajQNSlCrVCvdJapFl10XFwXXjEqzHKUiCxf5dAzukSzsIyUD89rn4YwSlx6+cgEVTnVBMs7o3GfrJRw== 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=DUefhzkjjEiO7/wVr6NH59dW8g/A4Tkn7dXnRQf3M5U=; b=Plk2ptwQjXB0yDR9M8jJc0APWLB5K8cQvsb3KPhgERhCBYlQY+fiJctMTfhzPEDD9ughMD1YawkdFTfFUAw/Jrn0bF7t4rqEyT6hz1E9ktqdFrxTuOGBxEdwaRYZ2owAUuOciWkHvGuw0Ai55gWkFjLIcxSNL0a6qWIFKGQKCiB+0EtKics6McOKggnu+Q7kbHnYLe/rptGBeAjc5ljjPAwYwUtvz6Hz1Dtl5CmZpmFhgosV8mO63ShrdhtlzW0MLlDDm5ULbWGzR4QzxTA727C9347xLyU561cyEFAjb3MlOyjEnIgxEXc0LmDK0U2lq8gfJP4NEodvzpy4quVnVA== 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=DUefhzkjjEiO7/wVr6NH59dW8g/A4Tkn7dXnRQf3M5U=; b=lCCEZd+efYrweKDDhrwdCEUx8P9lebQ4TWEEB9fFpTssSAZy1eliYTUjlW3o5Ec+kmKo9xWrPl2xpVY94AywJzdRoOPmMeZXwPkdH4bvDqKTrRyjT/29J1RM2HzXFUnJAs8tdfLJ+ysslUalqXbDiJZMvfsdRzIWhUKGwV+S/z0= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by IA0PR10MB6794.namprd10.prod.outlook.com (2603:10b6:208:43a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 20:51:12 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6838.028; Tue, 3 Oct 2023 20:51:12 +0000 From: Mike Christie To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH 07/12] scsi: sd: Fix sshdr use in sd_suspend_common Date: Tue, 3 Oct 2023 15:50:49 -0500 Message-Id: <20231003205054.84507-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003205054.84507-1-michael.christie@oracle.com> References: <20231003205054.84507-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR13CA0035.namprd13.prod.outlook.com (2603:10b6:5:bc::48) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|IA0PR10MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: 66bafd01-717d-4688-d2fc-08dbc4527a2d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gxS+7EW5/+TYkLJzpJs10fOc26JGn2aF4gmjZb3nW7nwj8UG7tBorUFZO2v2WpYAFharQY9+PfljLMTDptAVPzN64tsVkjIjjmpkw+IChe7Aqr/LoVXVLiWYJEm6Db0jqaZAIi1Tnylhwwm4CZ/aBcoxcFo65VoozFCG/OMdbMvNyxnZ5MXb1Gd6RGzYD+AjCW7Fp19JZVx8ctpenKI1tr5kCzi4DObLO4k5UKxONwU70MrG5NIPVd7qPzwMAuDBb3zdR6PVHJPjsgJguxz9kzsG3SntvrVoxoZCp8dH0fghYwjtK3hv/EUziF9e68HWuVcuWVIZxlxeEBEeCr+Gd5JcFqWs9BAu8AC62XWuWLpn35JGH0JswS/c4OQlHN45vhp15m3V0hlUU5g5QqiBNwSRbxlUpQrDItncVkfl00XJJb2FLTgZ7PVUblw3jouC38HKzF4OQQEjuyPssr2rsuA6bjyM9YGFFVmJF7cU2r6RNPfVlmxHPN3mhHp1zUCNZdWdDg6GyraEqGEfozS8B3lKKAMLNS1MLIWgMnpSUoE+0Ti6yvT5MkZyWrZsbc/m 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)(346002)(376002)(39860400002)(396003)(136003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(1076003)(107886003)(41300700001)(6486002)(2616005)(6506007)(316002)(6512007)(66556008)(66476007)(66946007)(8676002)(4326008)(8936002)(5660300002)(26005)(478600001)(6666004)(83380400001)(38100700002)(2906002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: suawp8bPJwxS07XHz1cTh1n6iN43RKnmMK1+9fa5L+fKuwtEVGJB77wdSxesRMKthl6tzZ6io6MdWIfXq6mjC46by4zfcAYkzSO7yKIrNSFqCUmuws8m0rS7PKJX3ewvsbGm3c7YVDth1TtzHexHr6bHee1PJ0jTJyS2at6k6W8WlaDd7OezJXE7FZsWmOj949NjpiwkpHztWieMJk0K51ZFtZqz3tExFqXfwGGgeWeeBUozUnf8k8hovKmXhDfb914lu9lDEJIww3r16/QTsGkJG4tpYJSx0CFRtuPu+SuGWBndGziImqE3I1fRtpJ+/2gxr+EDv24zpK5ApUP6+q9qQASzmcFfMLo+GL5IHZdbgnYp7zRCJXhpl+k71kyM4AtnS+DaGgRGFFwyqFMvRqFPsGPGoCiWDSDerZnlVWodLUm2mL2T/VeNEodGXv5VU8MnF2KQyIAE8p7aM4uoxQf2lYIuDJxzZ/xwxgWZSu2ogLxZCAlwE/1ne1h2BJhU4Fvi0AAiMs775qlQutYxDkZe2i2HKuzgtXzOpoJ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Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: pFAk15ZTABKK7qzLDxqRqJaZjmrk1Wwhfz+AdRbLmwhrsYSUI/MZQj4TKLdypEEwhhGQldnxNrcdg0tw7HPD8OXSpPFPPbsT8ORxlav66QhWCz/a71vSl0M2gCFDtIuGwC8FRe0jGQLI0tznmlNtgDqxzivFMVsiFp6uxlTeTvo5vmnEVSmo2/Ju48doCpTRaFvy28Fc7/YfAaB/KwtyYMy3KuiszX56cjNvNPk1vKt2kI/CjNTrXKPCH0enrIxE8SuSB6SL/U7tbetSm/VWmk03EO3W77Fc18G+wWiQ5e70jJYESRkFxmm3mnYi4cCjrQOCx6z4PVYOhBIBBj0/4x949BlzxiHbU5gkKYP1Uygm17I/SmBYdfW6mBNVVkaZPomWk/jeOv56PpqPuyb73+uKbRL91sOrD6BU00/WD8KPqI+8uKBzIL2l8C/oDMD9SKSPrO+j5SWxqYTYKGFNh12w5qePBQiGeArue+1a96V2wsR8suyXUqPQJPtL9RctZ8MRpMbjmWUdcjfrMAAQmmQy/Bal2dInPJj7WZ++N1q0VqHmxLJjW4L/k4K5ser/lMFZk2bO2EakMvquv1ru9ICqNF3ckMAZKKk719G81ORLLXp0oyl7X6yXDA+8CZxuTOz7A3vNtrvOVqLhcyVOike2i6M5BHZQrH1ig2pw74iIP7ZZUhI+uuNLa+JwG3A+V/uxfa1n2tGFrXJaZMMLGhyvm6BXZ5ETvO+9fuPabimewbQbQXzyFCcd6VhxTG4LYB4MoJGqip0DLE77p+rG8fDBOKOat6NAQ40nxukhZBTP5fYKEXVoqwfc1DXGxsc/Jq7TNcRG8B6VsuXwiGlnjxFXrVJMefYtqhtZbuiQif8mEb6KnrgL8d2Kmfyxqhpr X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66bafd01-717d-4688-d2fc-08dbc4527a2d X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 20:51:12.0455 (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: lsaswbqZ2h6q1r0TlLQjY3Uhbu30z6ih0y7HUSgvsJWJ6pdfnqJTEh9IH2rqh0ZZvwXlAtvPQeNLujJVS0mdgcLHz3pAkYgqqgyMN3poPp4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6794 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_18,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310030158 X-Proofpoint-ORIG-GUID: AEsNJKtjIfV1F4E_Radv1pj3VBeqSjvX X-Proofpoint-GUID: AEsNJKtjIfV1F4E_Radv1pj3VBeqSjvX 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. sd_sync_cache will only access the sshdr if it's been setup because it calls scsi_status_is_check_condition before accessing it. However, the sd_sync_cache caller, sd_suspend_common, does not check. sd_suspend_common is only checking for ILLEGAL_REQUEST which it's using to determine if the command is supported. If it's not it just ignores the error. So to fix its sshdr use this patch just moves that check to sd_sync_cache where it converts ILLEGAL_REQUEST to success/0. sd_suspend_common was ignoring that error and sd_shutdown doesn't check for errors so there will be no behavior changes. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: Martin Wilck --- drivers/scsi/sd.c | 53 ++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index dde9b6707980..75be368f3b5d 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1564,24 +1564,21 @@ static unsigned int sd_check_events(struct gendisk *disk, unsigned int clearing) return disk_changed ? DISK_EVENT_MEDIA_CHANGE : 0; } -static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) +static int sd_sync_cache(struct scsi_disk *sdkp) { int retries, res; struct scsi_device *sdp = sdkp->device; const int timeout = sdp->request_queue->rq_timeout * SD_FLUSH_TIMEOUT_MULTIPLIER; - struct scsi_sense_hdr my_sshdr; + struct scsi_sense_hdr sshdr; const struct scsi_exec_args exec_args = { .req_flags = BLK_MQ_REQ_PM, - /* caller might not be interested in sense, but we need it */ - .sshdr = sshdr ? : &my_sshdr, + .sshdr = &sshdr, }; if (!scsi_device_online(sdp)) return -ENODEV; - sshdr = exec_args.sshdr; - for (retries = 3; retries > 0; --retries) { unsigned char cmd[16] = { 0 }; @@ -1606,15 +1603,23 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr) return res; if (scsi_status_is_check_condition(res) && - scsi_sense_valid(sshdr)) { - sd_print_sense_hdr(sdkp, sshdr); + scsi_sense_valid(&sshdr)) { + sd_print_sense_hdr(sdkp, &sshdr); /* we need to evaluate the error return */ - if (sshdr->asc == 0x3a || /* medium not present */ - sshdr->asc == 0x20 || /* invalid command */ - (sshdr->asc == 0x74 && sshdr->ascq == 0x71)) /* drive is password locked */ + if (sshdr.asc == 0x3a || /* medium not present */ + sshdr.asc == 0x20 || /* invalid command */ + (sshdr.asc == 0x74 && sshdr.ascq == 0x71)) /* drive is password locked */ /* this is no error here */ return 0; + /* + * This drive doesn't support sync and there's not much + * we can do because this is called during shutdown + * or suspend so just return success so those operations + * can proceed. + */ + if (sshdr.sense_key == ILLEGAL_REQUEST) + return 0; } switch (host_byte(res)) { @@ -3769,7 +3774,7 @@ static void sd_shutdown(struct device *dev) if (sdkp->WCE && sdkp->media_present) { sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); - sd_sync_cache(sdkp, NULL); + sd_sync_cache(sdkp); } if (system_state != SYSTEM_RESTART && sdkp->device->manage_start_stop) { @@ -3781,7 +3786,6 @@ static void sd_shutdown(struct device *dev) static int sd_suspend_common(struct device *dev, bool ignore_stop_errors) { struct scsi_disk *sdkp = dev_get_drvdata(dev); - struct scsi_sense_hdr sshdr; int ret = 0; if (!sdkp) /* E.g.: runtime suspend following sd_remove() */ @@ -3790,24 +3794,13 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors) if (sdkp->WCE && sdkp->media_present) { if (!sdkp->device->silence_suspend) sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n"); - ret = sd_sync_cache(sdkp, &sshdr); - - if (ret) { - /* ignore OFFLINE device */ - if (ret == -ENODEV) - return 0; - - if (!scsi_sense_valid(&sshdr) || - sshdr.sense_key != ILLEGAL_REQUEST) - return ret; + ret = sd_sync_cache(sdkp); + /* ignore OFFLINE device */ + if (ret == -ENODEV) + return 0; - /* - * sshdr.sense_key == ILLEGAL_REQUEST means this drive - * doesn't support sync. There's not much to do and - * suspend shouldn't fail. - */ - ret = 0; - } + if (ret) + return ret; } if (sdkp->device->manage_start_stop) { From patchwork Tue Oct 3 20:50:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 729200 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 6FBD8E8FDB3 for ; Tue, 3 Oct 2023 20:53:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241112AbjJCUxd (ORCPT ); Tue, 3 Oct 2023 16:53:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241096AbjJCUx1 (ORCPT ); Tue, 3 Oct 2023 16:53:27 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3390C4 for ; Tue, 3 Oct 2023 13:53:23 -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 393I4n0u014375; Tue, 3 Oct 2023 20:51:15 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=paSmyk7o6XsX+aCqXGcuZtGqjxiA9Y/rhapD+j0iXlU=; b=MLbSxfTeo/UJCAdJluRmtXV+lV/doygSGRIoQxMGdQgqU2SyF1U0gD30JEf/SKvTR1er SpjvgJarUAq5srAdkXnT4ShdwfRLUCb11i3+FlRj6eJNxVwt9vJ+JJtST6IsYAjXKo3y FAh8xbYc33v/M6X+Bgbwy6wlDy/BExcJRFMhdsr3Qd9pPNQvey/cyRjsRqhSbDwNr7cV doyHnR2quOgxWsRR7xGITljEohTBolSVGox/cIpBupp/OPwXxEjF53ziKt/AIAa4ZC/H Mo0B4qoPr2JnEspiuNxRoCsuWyU7oSUdCA9QBFnO0zY6xyzsXhpAgrvFvq5Z9WQuxZa+ FQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tea925s05-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:15 +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 393K3kO3033640; Tue, 3 Oct 2023 20:51:14 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tea46tekh-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BEfxDF8Z9HKuh0YNJ+qmfLoCkMaFzARNtpImIJTPQOSj+M4aHnqb33YS3u9lH39o7h08+/eLsMBDt93rSh4r0ipBtm/KJQ6Zlnnq82D1jZspOZ3v5f1fVHB533fwxQRxNWVR2tNhskMTmG+Q9qEs5xQ2ctLBJnvVJwVvs38BJlmkFJ5jzfucJNrbI3idpnTme1kvsSxou49dDuZwPzzZuWgucwtxi8haFdBFgO2r7+q2Eqz5s1bgqLImbo4J1eqluMry55CrggdOOMnmrVDy/3SgUh3EKn+tNzvPp8oa0Bt7bFnB6mbFgy11pyiHwfWC/s+VZcrId/CW7+vU6JGRXQ== 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=paSmyk7o6XsX+aCqXGcuZtGqjxiA9Y/rhapD+j0iXlU=; b=YGfp2iIBTC+KXc4QdfOLvzHYwlHLHwykxpox3u0g/baj6FsqWnMwCtBD4L0UPpBpEgbSocX9Vb37bpAxYY9lO9ndCjRVHQ0/bLfZMZLzdZVImxfj5/RdEs4eZ35ko7VsLzLcjBElCYc2BBD8aQmV7G5T3uOVupEDUJ90DoSBXCvxw+QrDOa2HrXu3nz2/+Q9FsbZkT4YOnlr127p8yxGAjfKWnJe7s/hhuw6kpoHtyxChgnaESxyG7ngI+KtYzrya9gJFzzP5xz8IDqnLKeukcmZFcfkh/Ph+PBmwqZT+HW5pZHhS4zQ++Cu7gkzpZBXhFhWhki1FWI5LMmDpORuyg== 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=paSmyk7o6XsX+aCqXGcuZtGqjxiA9Y/rhapD+j0iXlU=; b=YWTM9zsMdDubp8NJ9WppSsGa2HrXYm1RfGguJ/zPKKx3HrtEKMs2ai3ohveNWk7+XOiMKpiCF8ywOjM3zurA8KaOd8JO22QU1/9SyvIfTPuK3UFjPTAWSGlLe3URP4xJGs+M5nwrMTkyoKqy1ehYW6iZbbjEsOx6boFDEiMrmXI= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by IA0PR10MB6794.namprd10.prod.outlook.com (2603:10b6:208:43a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 20:51:13 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6838.028; Tue, 3 Oct 2023 20:51:13 +0000 From: Mike Christie To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH 08/12] scsi: sd: Fix scsi_mode_sense caller's sshdr use Date: Tue, 3 Oct 2023 15:50:50 -0500 Message-Id: <20231003205054.84507-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003205054.84507-1-michael.christie@oracle.com> References: <20231003205054.84507-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR01CA0010.prod.exchangelabs.com (2603:10b6:5:296::15) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|IA0PR10MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: 5176d951-1f5a-457d-a7aa-08dbc4527b1e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gX7Rq77QNQr8SIDQWeAbMJyjM+J1LWuABge/ecIEPGsplLNJzP6R7m/CA1WQ2RVmV83I7lEj2S/ulYyV8SyptsUbug/Y7ktVBqsCnS0lZAZ1GQWeUPuFMEMZfRjvqhVi7iCkN2AlnhnWiTZhAPK92HCrWjNoM9jEk5IcvsdFqVzRhV139ABEjjx3M3U6pQ/tch9Pp5qitTZsPxBeNvR0L41/4QEdb7/IKQ3vP63RzhHuMFBO11o2JBB4BKPbPJJK7/FpBxv7pvBSYDQIh4L2oVO+hxb+BPq3cLJen/IA5vuQXLEcqI70BuylbrAhWX2BXXeCG5SkKk78McT45RByj/F2X5GpRCpn2GFriFvSoFLC32hAVK5qHhweiZwNWLduISKKCGMRlrjO4QKFm9PyYazGNstdSgkTSYhetTyoLfT0l+b3y7T3rYLmw/gCw6djBnRSNSWH8pINP1+2BLyCvGY+uTVh3cCkMBnsTlFm0Kxzm2J284eY6vIbmoQV2PfsXnTK7NtooP6bEr8P02hNrUuzZbBq31Fv0TWDM/lrws9UIGq2ZYnw3EnK4+J+EvqQ 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)(346002)(376002)(39860400002)(396003)(136003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(1076003)(107886003)(41300700001)(6486002)(2616005)(6506007)(316002)(6512007)(66556008)(66476007)(66946007)(8676002)(4326008)(8936002)(5660300002)(26005)(478600001)(6666004)(83380400001)(38100700002)(2906002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: wswB9jSbeEpHM6l6Bevt4YqpseDMH4opljZekSfq0V7OAcpTQ9ZJchtNkTrN0ZtaJDqLtyYWdHGPWz5F8tu5ji2t2uALaFiDMDq5V6OY+2eg7t9P9Z1CpN2PHPIJLCbt2M8ynPCAPRm8ny3j/zz03hZsvIy6C64b8sv59WwGicV12dYTNy45xt0PBBq7urZbN1JDQg23asugKr3Kl90iDivGBjMEa+ErEERioGqIPpcq5FPxBzZINVcZmjpP7l4A79sYUPFd6xfO2B2ZON0SPw/vv5/kzvkNkSg+QDXfrMPrA0LN0rmpGh7WqN9d4RQ1Cj1RPI9mkn2SpI2RSZBHZKvkg0hz+tHs9el1iv0JIRlAt+/lYFyEqYR6qf26Ezjj6M6tnVykQI/0UIl8qgYYZwV/16aRdYuQZ3wgENFrHni80bnT+4ogh7sTsXUG7OTprOwBH6ogNCvxPHbSP7lEmcLVCafry5L3VMwbwBDtQUYsA3cFmTMTZW4xlG91JxFVpOpMJjMYQdi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Zu14lFA3/IxKkcyEE5Bb2vGbuww== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ck+RwUWf1Tc42DgLDaIbxYh6iu6oOxMVYOUVYAmd6kV7owcW2V/VRyzZkUorH09Id/Hu+xKGIYTeCV2yKoX4M17flHDpWtzAKfTVaz9asT2kmV1QMF5U21wDGi93IZOLeqbmiuM7oZXVk65qZ6whq6hi25lfsJY0XerxmRMsOH5gRoW4m729GnSoo7fFQnzA5kjxn3wSI0Eh8WChMklcE6S9NZtDPNtmdESQXahTIpHxQhc4mpRHY7SzVzaXbSgE+YRBG7aIP/euOEpWIftTce/Ul4f9yzINmeds8DieAlv9G+jgLbhn6of438A7XBQfBNZwPFDKLQvMG3KLPCjb8gpx37/4ELuAiXqUwzQo8UUuXdrPPpw2bkRzxtopTw43DSicwTWrblpuaggaj26T1ZHT58GdcNDHpB/yFJ3J/8p3iA5w3WzMpPZEBPix0S9ovkEdQ9Jg0IcF0bilWqPU+T7tBcXp9PZhl60L8q/rgGUGy9usWFtUFyGNmhc9w8hxu8KXjadvXhPEGY5dzkX93OXoFFdDdyZtBjpIzhquqm7drL/sz+jVkOou/vRMuwT2pKaO+gkW9rosUeDzSlyzYDGxcAiZvp84HOCU+R4zh8sASroT2Gq79ERAAGI+sBz7TbaCLayxnt6Qxp5rB+cgsEajrz24FqPPvx6umAROru/O7nWNfMJU0ZnqPawg61gFDEuy6T34rAEENeWNC3iwn/uiR2ySh3ZrDmxeucxa17CAd45Cv9rHk+J+fnH3RPGTn74tALHOcetdiSH3NM2iBIYdPRNwRWdvGpNtMTxkTCk40hEwCT9IMYdepBIznfuqrJ+IJt1JBqy7PRLfseT3dspdRyMXcz4SkO9lXlqnU1RPPSEWSVw5tVLKvA8X34U3 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5176d951-1f5a-457d-a7aa-08dbc4527b1e X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 20:51:13.6034 (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: F/9NfbBnU57qwNwl4RiVZZrw5GM5rrcCvaH7LZ5YO8H8ZB9uWNt5Q5i6feL9DuAFSKp4VUdKgTDiMD4iBAICrgP9Ual2eidXaVWqT1zEg9w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6794 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_18,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 suspectscore=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310030158 X-Proofpoint-GUID: oKcpMxrTeoUL1UQjIj2PrZohN4oMF5TY X-Proofpoint-ORIG-GUID: oKcpMxrTeoUL1UQjIj2PrZohN4oMF5TY Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The sshdr passed into scsi_execute_cmd is only initialized if scsi_execute_cmd returns >= 0, and scsi_mode_sense will convert all non good statuses like check conditions to -EIO. This has scsi_mode_sense callers that were possibly accessing an uninitialized sshdrs to only access it if we got -EIO. Signed-off-by: Mike Christie Reviewed-by: Christoph Hellwig Reviewed-by: Martin Wilck --- drivers/scsi/sd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 75be368f3b5d..0dde64d55619 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2895,7 +2895,7 @@ sd_read_cache_type(struct scsi_disk *sdkp, unsigned char *buffer) } bad_sense: - if (scsi_sense_valid(&sshdr) && + if (res == -EIO && scsi_sense_valid(&sshdr) && sshdr.sense_key == ILLEGAL_REQUEST && sshdr.asc == 0x24 && sshdr.ascq == 0x0) /* Invalid field in CDB */ @@ -2943,7 +2943,7 @@ static void sd_read_app_tag_own(struct scsi_disk *sdkp, unsigned char *buffer) sd_first_printk(KERN_WARNING, sdkp, "getting Control mode page failed, assume no ATO\n"); - if (scsi_sense_valid(&sshdr)) + if (res == -EIO && scsi_sense_valid(&sshdr)) sd_print_sense_hdr(sdkp, &sshdr); return; From patchwork Tue Oct 3 20:50:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 729616 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 07600E8FDB6 for ; Tue, 3 Oct 2023 20:53:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241130AbjJCUxg (ORCPT ); Tue, 3 Oct 2023 16:53:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241131AbjJCUxb (ORCPT ); Tue, 3 Oct 2023 16:53:31 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A46C7DA for ; Tue, 3 Oct 2023 13:53:26 -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 393I4oPo014401; Tue, 3 Oct 2023 20:51:19 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=myIXlPUUs+aWF4FaahpIwHu04bdlMeLC/y41ApmW+iE=; b=OmISWbszS3AunAf8mEkOd1p7DfSYHoBRJ3S5dht9++1057l4OoNMTG7Rdbn+uQFMlhYO yDIeKV8MAfrK1XSkunkuOD9aqvh0zC6SeF11R0NpFCN9AAJfQBeEOtBaR7ZAjMc9F/C0 rA4dGYLJzzozjQdkNR5SlcOFH5k4qxtL5Z/xaj4o8ScQ/7FCeE32PG9nnWtwd8+6heBF 4XnNzZgLakqiSGBX5osQK5/jjbxTVGYrHcNsC3tjP8R+9hJ48y5VLDyVF4IxJLa5nuMV hgQBBVeSE50//Pn6NjO7q5NHl3xIiuv/O+TaAO2GLxpZUJkREaqOtnl7aXuce6jahMCk 6w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tea925s09-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:19 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 393K09YM000576; Tue, 3 Oct 2023 20:51:18 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2170.outbound.protection.outlook.com [104.47.57.170]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tea46j5nd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A5Cre+aeJD39eypsmCzMUNGNdJmDWRv6yC+vTTz1iYBoVApjKwoPgjNBHo9oT9Nh/Fvu2hia5NWkLy2kWY9QnIrGbyQ/4k2B9H4lOf/YvVk3BQcqpg5d8ojeYjbL2dPjDAaocjGlAnZkHWDt7KTH6pcFMHyU4LEA5WhsvMB2jY8BDQeksYum8mgT9HM0Xn+C7AO0qmUWm/X2iWDjXOa3kRMDCopIJzVgYC9fonD3RgXLOg+rBDhRPzVaA4YMqfeKuMKiT5iqgVRMHv/GvbHidKbytqybXj9HOJHhzV5ihmN+QNKa3OR+Eltayo0KonNiSBNHnXoSU3X8YxZTB1cBkQ== 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=myIXlPUUs+aWF4FaahpIwHu04bdlMeLC/y41ApmW+iE=; b=jKLCF8L+MyVcNsgXAmSbO/TKqT8xEwcd8S8cdhRBR7o79NfitQH148CubuiUDApzp/fVnusdxbpyH/mrGO9bE0ztkWxK94xbC2ORmqZOO4fkq6//jkOIq0iqOjC7lSY512VOJRM7GRXfd8Tt58KbNatrYQIARY210B0UFGgnERmgbWdK0mEyWsOfrIqt06zoVZkPoIIQ0H/Z9L5Jz10oIZA5tccQVMIjFRqeMhJ1FBttkS6J2QYJAKG3pO9zZRyx30Da4KQaLh/pwagadry4rBd0bMqxs88awuR8eixyxdX/fS7SJTw54z39+hDg+7CbjMDDI5unzTgCuzc/xRoz7Q== 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=myIXlPUUs+aWF4FaahpIwHu04bdlMeLC/y41ApmW+iE=; b=dAqCUq/o5zv8gc6LDEn4lts3VADQMo2n1+Omm/8+/mnHbG18807CQ35y9w/+AU+dZCY9/Tab9DQhdU7AzC9m9y4IJTcz9IZJJ0DYHitCxIZPkt5ClPusiusVySJ2ZZQt8ayl6Xmjw3OV72njGBQmtFATYZuz4EVb3RiYPQA7YtE= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by IA0PR10MB6794.namprd10.prod.outlook.com (2603:10b6:208:43a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 20:51:16 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6838.028; Tue, 3 Oct 2023 20:51:15 +0000 From: Mike Christie To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH 09/12] scsi: Fix sshdr use in scsi_test_unit_ready Date: Tue, 3 Oct 2023 15:50:51 -0500 Message-Id: <20231003205054.84507-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003205054.84507-1-michael.christie@oracle.com> References: <20231003205054.84507-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0177.namprd03.prod.outlook.com (2603:10b6:5:3b2::32) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|IA0PR10MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: ab7cf8da-a071-45e4-670d-08dbc4527c78 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FbhMzBitdyOWQMBS1RnK6Nrsz4zlJHanVstxSA5AXOnMYW8WJ2h8G0RWs9hvHGp24PsyB2LDNqRYWsUFBXcl6WAEPG4GrE7NfpNIHpB0Aq30Qva4brqfARvKW21CDUbYqKA/NXKwwkqPTm2f68P7CVpW1Tqdg8QlrIsIQCHhRlU2ah3aWxe9mDsu6NksIQ+LV1HXr4Cb+/FRoKDMV8L/0pVkq59QfhHO/X3Mi6pNpWI6zUV4gKXI2qUvbW3fsUso/F9vaLDRTU0fvC3mi3tVQpsPoE4raNsyg0cVp1tquB0Z+i50/ZThIblw2IJDgH+DKTs4QHwe80UTrLNGpxSWQUCFIEQ7WvxgRa92OHP1NHrSpKaoWjRAEONgydEy3F6ODCw5iQZUBznU3kkSBCXQzZIev9l0v6KVpmU3W9FaRUhwGHy5uNYqaFQL6N4PQcE8jWGbQXsA5Z42TM5cCg9fVrciwlSGVIO6Ncntd5WyQSxCWm46Yb37BxD2rxW+lsOjgnBB5wiLs+kWbLskU40AwcZKn6HbRP/TmDsMJvkRirVPYPKgl7ysQ7h+orYVKmPG 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)(346002)(376002)(39860400002)(396003)(136003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(1076003)(107886003)(41300700001)(6486002)(2616005)(6506007)(316002)(6512007)(66556008)(66476007)(66946007)(8676002)(4326008)(8936002)(5660300002)(26005)(478600001)(6666004)(83380400001)(38100700002)(2906002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kCoeWQEWClZa2HrDLpWRXtlCNGOlzOKM78eC7aUl9LVcAUgOJqNADA75rQys/gnQ0iG7mbQ8XyuiWPDBTU9kTEyEyuDLQJ4PWCDW2Nqmuh+mmGeDC8syBymyZYo4vrTpPNTe8LM8HfOG1dD2TdEa0eM9CZ9WeqmTMlCNfNN6IvI0TRzFVVF5ecWR1FluHLlt/Qfra3PVCGLpRuoTRZquo82Vic78sWJvJLFkkd2B8NBtG1ENgpoiVNRB3BwkE0863qs+ZtsyXSVxJW7ydecmhuR4cEP33GfRAVwyv556ewoGig3hqTL5DQ2DLe6MujX1YlO+EZiAOrBh9ew5hixAiblvV035Y5m3k6VHUmktZmGz3c9umGqNXYX1SnZuCE6a1gJi4sBpRJw99PMReAteqjWOwjFDdPC4iu4ZPQgsHoHZHxMPgiwzYCkphDINvLgHx3Rfum4AhZZuoV57qQpxuYPF9h18KgiPIbIBllLrzukDrT9hfN4xaBwbJwvgUz5hMP+0ta6HbG8B87Ec6x72QormJbnqF9Ss5/c0Vr0gXznT7Q5J6IBSBvO6qZrFqrBXMOFXllCVGu0lMV/UOJ0nr39b8FKL4t7f1JIWjksGkMb6hUO/1r4Tq51QuJdpBTpgQIFajNBwRNEhDVRXQ40IqcYbbT2i9bBqsU+B7SRux25PuFLQnzZlklh9Hb3CR69Yql7fZHkzHlYtZvLWsBl/BcdqdlzS219OpDdmmKH1wyP2wvq0HewtHPCYinhApAGcg4ABT1SN92ML2UVFok7PbIoAHMNALWB5n2uT28FEoeWs2+ELD7fLZo1KqipodASEvjp+90zCxVQzhso6Q1PNBm78Cv06RvgNDgRcz491cHzCI6MGnYwmP1KdeI+91oq+cQw0AFYW0gVYtxVtZmiRkdSgRc1742UhZynl1WGu1JCenkQg6dPsXedZxBN9aFydYJYb0GQAzxhpHyR8HJ8Xt1OvT2iohgRlJ7fzF+lruha/sBhakafrDlICt4BY7tiNluW2EyptjA6EjHJcXnjhS0BMuFmCVpM4oU/vigfzMDGZq9NknNjORR3S62kxWNXmM5QKhMVjaZDZGM2A84GqZDPF4O6Z32RVug0zFCVuIiQxqgn1ZzS4WVviqkbYESJTFN4itCtEaS8LMyN8JNowmfhAtRma4+6l8EmkYnCtBmCvyxbnWK3M1CZMBalCI6HiTszoiLFnd2/XeY6NU3cuL1zG3uuBRloJTEImxMyka/5gPRGLJSSVlAHY8uPZrW+NT6ZjqIuVMkfUW8q2qbhleNlG/Cq1fchc63Lw0Nilu7OedDNkpXt4/BHA6XH582c4A52wb0HbC22ng+NE/r8+eBInvS/ZjWeyjOwzuMHfYKaHVw10F7mXC01whH+QwYH39Mk3LpjE3gZmo7iL/H8Guy12EjI0E5ogiFrh27DRn1Q8IU3afvdF2+jb6v5zOgRWmVn2O705qCzYi1k2i8LR+E5pnaF8mgiyU+YNhlxwCd0MmN0W4HxGAn/wotlcd/xA+qhCchaE2G5HXFSTeY/MY+4NwbqBLwtqL+0oGxuexnuqEIR8lhnLTombmqXOzrvCPNQHLBjqW1VeQeYxB7la9w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Fku2Wq6kAa1+pnd7wc1kSUVSs7IWmiNKER/RY8L25BO4FoN5FwCqmk6Aop51ha/9kZQuhUNEvD/+gwl9IknmRMldTb/UZDC1+bIyx8H/5Epnn5YMkVgrlW8u3FemW/lFILYc/8kE3gXN6J1ZPGGyu2qJkI6NLHW7wk0LApg+FKsRuHWfn61Dop9H8gdT8sjRVCjXoynUCf3wVXyWcvE6eVVAEcT+3bgXVO0uCI6XjgiTVb7p9PuImrrR0494N4g5SmXcsljn4bswztqKuUKfx9ZGuEXcFJELFm/3s7Q8D7H1/IXdg+uN372SGejk7rKGtCL20LEnhBdlD7HQyUBadsDvAu3GPO8r71EKH25Ec9YJw3El5rp+8Qevf1np3VMXlfNwrx+hepqXRDvvvvKqDER6nZilKFnTOaGYt3ADH/N7wFOYLWN75p95bAYIge6xD0V+lxFidrMBhWa1kbwf6VyQsJ6JSzwgTW9y3DHetnbuGnfkNUc588vbIKmunRARGyEyBAnQNIFuXHwWuPc40M/Ct0za9g2VLC7P/YfF3Pwi2jWJElFjJAIS27qFoMhvJ7tFZmUSL0mt2mM5SnuE3WW+kRg1vEn6TnTpsDuYZTL3jb2Q3qTcCJXI9GtG+roTLnGtn/ZjRPNULcONMFee9P/dHBwNZGE0gLcyI7H+yylF479ZZZD8DWJBoi9+6LaJmopLm8PmFfARbtfj5BcP/BdnSQG7UPi6FDSi8ap27U9+2j6GjYG+mywuKHwHwqrVyctHH0jtXbGoeAFfbxDYpeBmXCtp6JqaWiuEdz9lq5F4owrIDo1wn3ljx/73bNsu2WlcEgyGWZH+LUjMYA62xLKgO2epdSrqVIGh3GxpAe5XMzaSJt70DCwA8wqOT4rC X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ab7cf8da-a071-45e4-670d-08dbc4527c78 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 20:51:15.8936 (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: z0Mw1sZVeLQRh0bmaTuP8DSih9+mTdx/SJ56RG5XfFS8BUk40wpI/qgN0Gwjbh01+Munwkv96r506VfCQr/DWoaUVXwgjybMk3Mq/Ew33yg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6794 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_18,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310030158 X-Proofpoint-GUID: 1OlAsfdjcvfO__A9CAo-KcpLDlOM1wSs X-Proofpoint-ORIG-GUID: 1OlAsfdjcvfO__A9CAo-KcpLDlOM1wSs 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 c2f647a7c1b0..195ca80667d0 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2299,10 +2299,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; From patchwork Tue Oct 3 20:50:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 729198 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 69672E8FDB6 for ; Tue, 3 Oct 2023 20:53:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241116AbjJCUxp (ORCPT ); Tue, 3 Oct 2023 16:53:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241126AbjJCUxe (ORCPT ); Tue, 3 Oct 2023 16:53:34 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 028F4E5 for ; Tue, 3 Oct 2023 13:53:28 -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 393I55in006253; Tue, 3 Oct 2023 20:51:20 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=bYuYfq0KX1VWy+GQhMkFCKnktr0DaIP/0QSWrqmtqbY=; b=vNwTIATRtSwmpw+baJ635WyAh6SwdrE/u3/J/rnszosnDd0/K4FVso61nQbTFwxUc9v+ QirdizDRF+ybm/drDGYio6O+b8SI/MCihitXbqtlv56hf3H3lpv5/6oTumuH6IbIve9y 8tN/tAjcXeM14/F0aDaDIdrLoxidK6MA8aKU3+4ERLl/fKmoP5ZrxG12dKIsdzozEn5Y cOCt7vu/N9IIxcEehO7rtJ4kYrLBe3rtLgLUn6wM+icIqYCoy1EKJxeBavmQ7RSyicbO OYzfXOgoVZhLXfO/LVIdkTLboX7gfxSC4dZcycDeNHrNJn8/LEUu6XTri1xFa1oXz+9u yQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tec7vdnrn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:20 +0000 Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 393K99te008651; Tue, 3 Oct 2023 20:51:19 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tea47425h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MHyEYP+Oq9/mt+9lgkAhgWxNgHMU658nnF6HXLCjWt4M5o11kY+kSHIUbjcV8/TZRShYc+hFBs8gD76lxiflKnjqo6a+/dyXbgo6TUoRtTiyiIle/fuHVnk3dWXhpN52gyliBU4agaAvfBqTg6BKInYeAfP2ljE5afWpwViQnsqUKDw0fpaDBenuqhNmibkC6VS0/VgVotCPNIk/SPi39uCxIVixCLj7vx+aJqM9uI0fu0cSVzf6TqMagzjslGVb87J1/qmD7ttzRtWVDOvK7Bj2nj71c/gVKwLw+wKTY/pCsLKQwFawppMoSOzBFJQ0woJ7vZWd5VM88eWKwWSxmA== 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=bYuYfq0KX1VWy+GQhMkFCKnktr0DaIP/0QSWrqmtqbY=; b=bP4F5vPZ2wtR70JUX+YZaXLWXC6I27vhGERYDs2BopT2vpNlWa7mFWYMQ7VuhvfTaHhbYF7GCjBvlaVlBDBmkaNLakqav/ElltoGH/e3drWfV0DDQQZr3hvz0Y+Xwb7qlrU+y4FH7UOVkobGd80nNZET9Tb6XkVR1Wm1se18ycBsTeWp8bq/A8eKJMBUiem+zEH1pGhonerLV/qiiCMFMGDokBdt2KMDNf50C4dOsvBzm4B1pSYijoci0krrGH/eSKT153iM/ZdperAh1Cedpk2vzt1zBV6CZ28mjZyPP9Z6vft965Wa6h8LEz9N5fp2FDvAVJWzZ3tfGCH09uTLfw== 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=bYuYfq0KX1VWy+GQhMkFCKnktr0DaIP/0QSWrqmtqbY=; b=GHdX0WTXGGzkm3o0YVX/BCTghNDmReq6g856iE/XUP6SJTdj4mAkXXzH54Bxixj/mfylDYBqaH4WkYdkVfa5cOUUsS/puQ+/SKLW9xiWqc+XSYbRITzK6TUU3Q9cQAgFrwK0w8Oze+IkrPPuQ7tCsDuzMUUpB2/ur89HzKVZSwA= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by IA0PR10MB6794.namprd10.prod.outlook.com (2603:10b6:208:43a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 20:51:17 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6838.028; Tue, 3 Oct 2023 20:51:17 +0000 From: Mike Christie To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH 10/12] scsi: Fix sshdr use in scsi_cdl_enable Date: Tue, 3 Oct 2023 15:50:52 -0500 Message-Id: <20231003205054.84507-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003205054.84507-1-michael.christie@oracle.com> References: <20231003205054.84507-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR01CA0018.prod.exchangelabs.com (2603:10b6:5:296::23) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|IA0PR10MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e45828e-75e6-482f-c501-08dbc4527d91 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NYLIbPHOuyTHf1aUO45l++QEqfSBYnBESEMDy2CMyv+GRxVqu/SRHBphlIRDTDjGNkvFp0wDDDWc6zAmzPxBsAha2Cxeqhdbgx0ayp26Kj6FsoB3QuhoGUDmYnl0TGY/K3uIOHdqa83vCtCEbRqELxG+XJonHtjQ95d5HqRp8xPJJLAUtjoEXw2o+em2XFYFa+ar+ahLhvhRUCgyylNsCezrT2LkswG/38WODnzoL5iOFCfSKmRAbp413v8gX+FmFSp+2PHh74ZXOcEaC8LvV0hONRYSy4k8XzPx8uS29FK3H92e0Ppopc9ucJroyxrEUke4GdomsXJv8NCRxUORind/kxQVXydiTqOW/XPK9qosEXKUJWz2GXo+Pd00NRJ4lqZh/7DQqiLjgWRlqlgUkDPhXaEEeISX/IdWmyrPB8ga/ame5S1DRJjjJHz8USIgb39dc6emoi1KoZkzQk4HSqc0xvgcBbOLQY+ZrhEbBwjMJ1KKXbjqOSxV4f1KpZxQc2LeZpVL5RsP2oUr/PH5gnSj/asfqfo0FJKy4pMTPVfz7iECjxOnrODHdYF7Fanc 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)(346002)(376002)(39860400002)(396003)(136003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(1076003)(107886003)(41300700001)(6486002)(2616005)(6506007)(316002)(6512007)(66556008)(66476007)(66946007)(8676002)(4326008)(8936002)(5660300002)(26005)(478600001)(6666004)(83380400001)(38100700002)(2906002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RrkwhUCDT7zt5P/T6xjv2Z1tG8kc742gWamOBZha3Zfy6EKe7mnKFDIO794XUwETaK1qS/2+DBxtg3d2WLly9nnDEal2awNNv7+ZRC5CI1TytwDDzqUz1a1aws8oGmqQCVuP+0O/yOncvSM5wNBgDIoj/Lxmde7qx2TcgxKyk5DIKXs5Bd6nPzntD2N9QKbjMX0Yx7c8N6r1sdBiEGkJTR5XojkH7A37pQLsCj5Z6T7/cyA0qNSX6BVNO60RtFhHua8RZrIKijQ1wf4dYgqzCw+unnpgcMHQ2Ot3HDmWH1UzCGrVByP7me3+6CWkItQE4f0+rXHZULNX5C89Ax4ddJ70+DmO13vzsU2ucaurC22E7ER2q3vdyNkyByxU/z+fCjmXw3dyf+Zvj8NwQclLwJfurl/YtlMtND8Yxga8Qb8J6SSUA+67+9Zb59qJNpCkf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le.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e45828e-75e6-482f-c501-08dbc4527d91 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 20:51:17.7337 (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: cb+ANdmgVEhlTeQCL8dxzAAHDF/LzqWww4WcAQl1Efn5q1mel7Ndq/sXat0GpTnkkAfGiIJTMnY/eyF+s6jBOmmOYfs0DRQpv7MufKBVk8Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6794 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_18,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 spamscore=0 phishscore=0 bulkscore=0 mlxlogscore=999 suspectscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310030158 X-Proofpoint-ORIG-GUID: QugtZk3Dasa47SgtUf50Wxt_Des_Cs01 X-Proofpoint-GUID: QugtZk3Dasa47SgtUf50Wxt_Des_Cs01 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.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c index d0911bc28663..d1c0ba3ef1f5 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -692,7 +692,7 @@ int scsi_cdl_enable(struct scsi_device *sdev, bool enable) ret = scsi_mode_select(sdev, 1, 0, buf_data, len, 5 * HZ, 3, &data, &sshdr); if (ret) { - if (scsi_sense_valid(&sshdr)) + if (ret > 0 && scsi_sense_valid(&sshdr)) scsi_print_sense_hdr(sdev, dev_name(&sdev->sdev_gendev), &sshdr); return ret; From patchwork Tue Oct 3 20:50:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 729620 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 74C4DE8FDB6 for ; Tue, 3 Oct 2023 20:51:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241091AbjJCUvf (ORCPT ); Tue, 3 Oct 2023 16:51:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241090AbjJCUve (ORCPT ); Tue, 3 Oct 2023 16:51:34 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07B83AC for ; Tue, 3 Oct 2023 13:51:31 -0700 (PDT) Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 393I4MKe027071; Tue, 3 Oct 2023 20:51:23 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=J4S2m+rt17+Z1FtntH0/aTzUZMtsLRWxZpcvrDq38no=; b=si9SUGiznx+3feXSiFp6Ml9s0GLcz9DthViJQKuUP5oQAtdPrHDNGLOY3wIi7v6YD3bD Q6vDtA5mWK+/57MRyXBMzTXRTvTCh6C3yRA3pJkYMy7ew5EBqoZHuC4+qsfiqiNDF5j1 xCBxcBY8EyZhwabYQfBK7QA02HMRC+jpdGxqD1cLUP+rUMExVwl3hFXqoqmLUWdvAKtC SVsHjjyUAoBT3cXo0thROcXT7vsBVH1f+9lu4qZJ0KSyOA3MZ5g3SjSN2Xb1CNOsNw9F HzcaAb4mxhZTsghDTf79BO8OAEnSWs/RlANKhloovu6RWWz5uG9sewcBcKhncoj3MCi2 7A== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3teaf45r6p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:22 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 393K1iq1003023; Tue, 3 Oct 2023 20:51:22 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2174.outbound.protection.outlook.com [104.47.57.174]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tea46kvhd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kOvG5TnBrawaljkbgLbWmn9KRsACkmD5n1kfRzlnIo2gxvPEJ/ODMsEeZLVAb7ELkriOgkU/mAgAxx8/8WTbYgUpkwkHcYbTNnkG68z2dUFMUl0vfEtpTRvIwVbwuCPL6RqD5T4ul7+F9UNMFS514SuV70OQHeZluO+byZnPf2X2XKERQhO+9DIpePfA0u/wxh14wIZPzO5DXBHJ5vN63bYpOZ1ic0nh9MDCNnMT/gHeUH1vfkzlkfZOckGQw/YoE7gk9QrJrMrIXt+km4MyL2hJ805NaHyDv7M/aVOFsSZxtd9EDqo6d5HzSBGUrHOtKxIioykzQPDimlWaI5BD6Q== 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=J4S2m+rt17+Z1FtntH0/aTzUZMtsLRWxZpcvrDq38no=; b=ENGcvNRInA2X2BVBniRcL2GVxz4Ub2Px0fCnENzXGmSu4tvaJemRNAHaJCo6rdQHCsOooeUfHsPxmI90w3jlZUNfmulJsZgXCdI5OAoUPafYNW228ZZi01mOGONV0nkwCDfO029czUDLeJgfjc3DYZa8t+XhWauIS8nTIyYAH5fwC6r3oBV20gXP/TEvSxgfnjtol5VExg9GH+yzaw5qttt8DRSz+a+PmL0hYi1cfGLfz7ldwE8RB9CoWd/NoMqpgGhgSC1XQBtGtmAyTA5LywpE7TmNWB9XNnueKHHzp56JYOoawAjq6NFm3hcW8FF0TmZ9lgtMAKyquR8bcMxxEg== 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=J4S2m+rt17+Z1FtntH0/aTzUZMtsLRWxZpcvrDq38no=; b=AulvUH0vqNARKQeJfZyIn5pQkxHwx1DlNIQOqcQ/vBllmT503sJw58WWQtKmnUaMgS/agjm+XyUf2LlQwMKpfrhLC1PytApN3N2GDRKLBk9GsnKiv6R/C3e2GIHVRn24jEdIA7tmpc3lRcHYEdUPjh5NgjU7XR4GG4Bwq4sc4XY= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by IA0PR10MB6794.namprd10.prod.outlook.com (2603:10b6:208:43a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 20:51:20 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6838.028; Tue, 3 Oct 2023 20:51:20 +0000 From: Mike Christie To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH 11/12] scsi: sd: Fix sshdr use in cache_type_store Date: Tue, 3 Oct 2023 15:50:53 -0500 Message-Id: <20231003205054.84507-12-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003205054.84507-1-michael.christie@oracle.com> References: <20231003205054.84507-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0137.namprd03.prod.outlook.com (2603:10b6:5:3b4::22) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|IA0PR10MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: 68a0ce00-0b85-47d5-d2d0-08dbc4527ef9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2MXVvIKSMsLD51XuJpDsojZWIy8V1obCcsOgELSFMFqjdQfQ0tahs85ApZ1bvvdlm8rTWIt8vqw5FBd8WuEPcdTgz1D6sa26hrksEet1imoQT3q2tNdAMLRi8Qzhge9vHJMDMQKncGs/TmsDVw7HagdUSlW5I/7RRUGFxkeJ083wp6cWfPrwHPnX78xaBKDGaLY94miU28c6GrGhGALapKVI7T/ianU9yadEZxCmrOQrz/YwZxZKbjKAHPHSDv3I5n9jHZ+hMYz2rPq2Yq9BfOVIFiC85ezU6gUkK/GOgUwmpzFVInJsp5ARuMU2YJeCaXAJulNgm6RHaMtPtAOMjddkALhUJQ3LoMqMni5XWKNWfi5rDWA5RFx3ZJyDSFqnw7qgd6DuO79LWq0IaAC11c1vYKfWOrmeigqJpZDggtr6/mjdh/quSMORPcvBgUmBr6TY+QF/ssnr3XTYihxhwtU0wwoNPYvY6QZvOat07ilouYfVP7kFM1PcJbDiGog2HphmxgyLV2xQePNEe6WwO3Rw8AVd6GZG4/K7sGSYCn5T62+WsvEGxi4TH+1MNe6x 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)(346002)(376002)(39860400002)(396003)(136003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(1076003)(107886003)(41300700001)(6486002)(2616005)(6506007)(316002)(6512007)(66556008)(66476007)(66946007)(8676002)(4326008)(8936002)(5660300002)(26005)(478600001)(6666004)(83380400001)(38100700002)(2906002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-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KaDeRZav3KdYd5B40Rr3KknNszp1R0K0zZN6pOYAChemTGBZo8DlDFryAM48Nk94h8UrWn/6ebRLdmRg3MRaxSS6BhkvE1E+3emW7rCOxdXEAG4mvrTyP6/GaLrqO0P8zix4lroW/rhWZdjThapzBvKvkQEqxIRo10UdH+GAgrsZwzFYWaAgXmdAPpZJYEGtLyV2E+cDozySOTgbMXQqDiFcaIMfwszK6GN4FWX/iUtbpH6DxWh/hLr88gD3lRd1NhfClgIVbN3zxtum4i0kU7i2RdScdxE1wkPLI84yYg0chilpuGVdz2Lzn+BtlZ7xnfKXIXukdfnbWIzAEPAoAz4JvYMKX8ynpJ+kGzbem1NybhKhzuokUlQT2+LdgdPuV7Nw/ogMh1WJmTTZVw3+pyPAuNyH+4jH2BvaEdQfSoho5gXtmhH7sXOCn9P5puqGENj/BZL4MFh6WExmPwldKgH1QxuHNwxFrMWgw5TEtJeKIETjhYeMCd/qoZwb37fA2umKC+nFk9dFkYVJ8wJSsjMVh3z1w== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: YzD70dHvy4Xv4UXxVogpNJSB6byT79atSyrNOtELQnFQqyb9eqsQ70EFqE4Ne7SKcdvizDWgdNfjVFavyOs2diXh4o2FTkGpCCMyem3QsOwdmKB55kcSXpxwu2J2xevis/GMQHZowN53nOKpr6Jh5bT7T2BotihXCwt5E/V4pdsHFnRuQtbSJYULIYLE0Q7Kvthzh+b9wTd9fFd/ivGhz9Rw3wPYSkW6kgtC/E4SHFgwmndqI9H/ly7h5eCH0qTTq1UjJuXFhjr3GJhAC0hMzLYRSEBkak/BPYcT/WJeA8Ykx0Pw6quZPaFJprZNuwNLBDqfy/u0o03agTu04byDjNv8KOAJYQ+LgA76qdZsezgOZo0/YbdPuzqP//AlvjaWstTrSys0WjobopjhRgC53qAQYvnrcQNV9ZQceP/302m2Qe+WmLvDFa7nS6sjZkFMh60wjaWXYSS46YwErmorr8KVGps72xMSkJWkulhgiDf9CdUsb6H02eeoj4yVO3joYEoPVuXRZsEAeX/2f6CLYQYDOM6WPDrXCCbPuKnYdLXOmrhagiLVZuH1ImFIC30UwIrccMKycEb6AxXjFsRZUj1HcDpUbRRo/DX891VzxqGlCQJWk4JHimr84gedJcm92848dtEdQcSBdBSOPouiExFbIv05scdJX8qGSwQnoyFDXGluKdQwTrP410O206UjwUAz3GTs3R0EXhTpwhCGMWbjkRCoR3pBtpG8n5RzEwjXlreZb0XZbi4NIBtpPlxiG7y4dlBfFM76KX/dyw60sV6fQu80pZmcEpTSvRTSEU1l3zhysB9sBtIcicBcq0iQXZSBJzPjrz0cXyzABvx/po9eSQZL0ioRjMfKTwJhNqnZcmteOe827jAv9LzrH3kX X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68a0ce00-0b85-47d5-d2d0-08dbc4527ef9 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 20:51:20.0631 (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: uOVKh8ypJw2dST57b0W8xVhmEj8wMqX4iU/yhEd5U3hqVeaminDk21s20Y5/gzyO1Dyr2xWEjab3jK78mFzRo1Lr86SVylcC+KHOrJvp5n4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6794 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_18,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxlogscore=999 mlxscore=0 spamscore=0 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310030158 X-Proofpoint-GUID: oVBJVV9FjMHagVv5iIPwUSa7ti49R1Am X-Proofpoint-ORIG-GUID: oVBJVV9FjMHagVv5iIPwUSa7ti49R1Am 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/sd.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 0dde64d55619..5c4a22d5c6ac 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -143,7 +143,7 @@ cache_type_store(struct device *dev, struct device_attribute *attr, struct scsi_mode_data data; struct scsi_sense_hdr sshdr; static const char temp[] = "temporary "; - int len; + int len, ret; if (sdp->type != TYPE_DISK && sdp->type != TYPE_ZBC) /* no cache control on RBC devices; theoretically they @@ -190,9 +190,10 @@ cache_type_store(struct device *dev, struct device_attribute *attr, */ data.device_specific = 0; - if (scsi_mode_select(sdp, 1, sp, buffer_data, len, SD_TIMEOUT, - sdkp->max_retries, &data, &sshdr)) { - if (scsi_sense_valid(&sshdr)) + ret = scsi_mode_select(sdp, 1, sp, buffer_data, len, SD_TIMEOUT, + sdkp->max_retries, &data, &sshdr); + if (ret) { + if (ret > 0 && scsi_sense_valid(&sshdr)) sd_print_sense_hdr(sdkp, &sshdr); return -EINVAL; } From patchwork Tue Oct 3 20:50:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 729202 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 AC571E8FDB6 for ; Tue, 3 Oct 2023 20:51:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241094AbjJCUvj (ORCPT ); Tue, 3 Oct 2023 16:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241090AbjJCUvg (ORCPT ); Tue, 3 Oct 2023 16:51:36 -0400 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34E22AC for ; Tue, 3 Oct 2023 13:51:34 -0700 (PDT) Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 393I4AHx025017; Tue, 3 Oct 2023 20:51:25 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=jRiB79JWME0fB9GF2PCATXgDxhvS4u19VZe6zw4kxpc=; b=sxD3lxNcMM+I6m3rJ1JH4Nv3xVZVGmTmuSrCCIU1ec5dAQtcCWfQRGM5w4rvY/+v6r5v DCwPkNblckWFchfQEhxZzOQ963d9N/B4eeGWX+myAi8vlm3bYPZ7M+zO48ZhVigo3wro yhWrIGLWbiUK4jkAWc4XV5zna2ZBv9sigmcmOhXkYYQa6ejazOuNs40CB4PTB4RuhuQN aQ8N9o2QHVEPgTZzc4jXlLHI4/c8PebYswxFGM23M3SjDygIutHrkkCsCdhXlqUNOpoi gwTYSLMhkkvF2npqCoDC3QCVTO+Pk2mP/SVFaFaNCEtVgYUnVlw3/TWCIjmEdGbIuBPB MA== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tebqdwqft-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:24 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 393K1L00000426; Tue, 3 Oct 2023 20:51:23 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2171.outbound.protection.outlook.com [104.47.57.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tea46j5r7-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Oct 2023 20:51:23 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ADWWJljbv0cwWZsZxalbSKAVWPMYqtPnl+iumocV1cjDPTsCH3MO6aVM3E31jblhKK2qgmZ6wnwaeqiFbFL9B+tI7SS/Aaaw7evEKIoTvyppPyuxHsIKUAQxlWlc627TK7W7ZHktqjWwkuFgCXbi/KezdXztMogkvuc4uX3PMcJlsKzKe7yjz2eR/GAWvZZEOb7rsv6WjzaK+Wjv6ouI64WzQYkcVxQZY4lxjWQECKk3rTCruefPN4tNZ5nzmCBkzKhmECwZiLz1q0+CU0a8EO1QhzMx0MLpTKedks/8BbxkSWiN0RHvrh/ut/LIknaRrRyjuCOV/3WHffUxqraEcA== 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=jRiB79JWME0fB9GF2PCATXgDxhvS4u19VZe6zw4kxpc=; b=BQe0yPLvqmybECOtTXfOE7elj+Esn8ii6lkqltWcsRUKLdyKy4FJBosxWBWMshfeRR6KTlBmvbrgQ545wVV4zxK6bDwq+egrtOxFoX5ezUKGGWya8bTRie/DdmWoWUG72KqG6nV9Fx+tM7nt5ZKndfUq+XsAWec4UDa0S50leIepvOzPswv2Ck5e9yygBvcjXcGdGHMRx9v4JtRfoH61xFg3T6TpA22P6S6/7aWdfGvu5GanDnuz5S2OARscXdd2IDh6cflvzK3L7zfT8OpPF/92W7ZdHz4yLtlorieP9IrXu92NHMSS83l3lgggv4e2sI4DJSQlB+3bQh/RirPP7g== 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=jRiB79JWME0fB9GF2PCATXgDxhvS4u19VZe6zw4kxpc=; b=qJEbb2j+Hn345URFQi3IWDaFpDEdHG0MIYHIkmaiJ5F8r9YDaodmDnlor4LjBGwVhHZjZ7+jHzRqLFZSUMCkDJHZcJW16cQFjmHMqlb/CiOP81AaBbV0qlgU/0xrVD2P5SNkMzAuUWnMmp9mf8LMG6fpFlbKPCDROXz7dEsiU2o= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by IA0PR10MB6794.namprd10.prod.outlook.com (2603:10b6:208:43a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 20:51:21 +0000 Received: from CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8]) by CY8PR10MB7243.namprd10.prod.outlook.com ([fe80::37c3:3be:d433:74e8%7]) with mapi id 15.20.6838.028; Tue, 3 Oct 2023 20:51:21 +0000 From: Mike Christie To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org, hch@lst.de, martin.petersen@oracle.com, linux-scsi@vger.kernel.org, james.bottomley@hansenpartnership.com Cc: Mike Christie Subject: [PATCH 12/12] scsi: sr: Fix sshdr use in sr_get_events Date: Tue, 3 Oct 2023 15:50:54 -0500 Message-Id: <20231003205054.84507-13-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003205054.84507-1-michael.christie@oracle.com> References: <20231003205054.84507-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR06CA0003.namprd06.prod.outlook.com (2603:10b6:5:120::16) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|IA0PR10MB6794:EE_ X-MS-Office365-Filtering-Correlation-Id: 4354b7c1-8726-46ee-93a7-08dbc4527ff6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IbuLm87NVluzbB1IQZHYku4OuSFEPo7NaoaREoX5h+Pjyw4JhQkpN/jl8Zv11ORNbCZhjJoGLUN4b7s6/5V14wKJ0XE/HxZWEYzk3h/3dsneQajGSDt6TNZR8rVYCn8LAJpbtBLcPrDKGsmRi7fgI2sy9FmCtrjufbhPiGOX6Xc8QoNGYjvJKKQftbsUyR+BobQ1NZGALZqr3TkhDw+4JCQTBOqKYRp9FFQxdeJBAN2qtLXZUpePi2wimvuNi8BWZxNuxZOEfXjDCkmaaV/v6myw8gLFUmvDzK8YJCxF2Q6T2dWTAR+4vbTDenGHbUShcK66QVEGqdhRVP0Q8XWUq5ACduwQ8RlDC4NY9hd/mHCgFzlMSHQ92TbGupW3Inl4g0KgYmuGBZJkdhNrXfuod+HLF93fciqlViXbJ0zlizEio8Q+3JfP4PZIOwSmOiRpcBNLGEVYF9Afd6P24dd4r27iYj/ouSPgwbr0lGgq/uIxhAWu6fT42/oOkM6zkMkKe3X4tFbXG7pTAg+Y/a7SuK4IzhyeI5GinBUdkRCqOxZMQi2SEp6q1ku87JALM5aV 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)(346002)(376002)(39860400002)(396003)(136003)(366004)(230922051799003)(1800799009)(451199024)(186009)(64100799003)(1076003)(107886003)(41300700001)(6486002)(2616005)(6506007)(316002)(6512007)(66556008)(66476007)(66946007)(8676002)(4326008)(8936002)(5660300002)(26005)(478600001)(6666004)(83380400001)(38100700002)(2906002)(36756003)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lsFXUcgWZgOlHzn9D41xas6CNGNKxwBRCGDqmytETLgB+Z7QSQTf4zBo7FrA6kHpgqWrwZkigRwlHrcoOEmeFBOkeiUEeKlZpi/CVcQrp4fYvCaNCXp/o/fvEFBRMP/dO0Zq3JYpkwEGEPlskBlBAQoZnEXaqzNa6gG2tXsYKPYUEApp3YBlfaIU8MgPOotwtAvtaMXrBsp2GLWJzO2EKL4Zc2Ax5o1yRaHcKDJopDRsyOMbSndFdERPczIE2Zaqa1A8XksfodF/AnmW0nnQAGHdan9iGtFl3o9FjiSb3GAvPuP7ljxCX/yrLiqb+0ZgphCKZSuU9ucD8uUU5VqGwoik23LYcZc/UTBH6TYcaqS7E7VgqXAnKsV6cdoaYX3dDoJv87Sj/uDvhVQg6HipCtg/WzAGOc4PvUYaIc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M7160nbO75XwJo+Ah4ixqJFBUh2nK27Z+jZUML+XG2VYgpp5sb9OMtQlrQIxAReI07wMoOhIjW2zYMVxNF/1o0N2bWxC2EEqesAY81t72Fs+s7CFvsuTvCEaQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: YsWvgrFzi7H3rpFiZAxIDgnVLgW+L1jpL7fOn7/jMO3FIIL+J5mCgh/E3X8N4WilocPjNNBr6q2p7EKHjbG7GFXRreSJY43jwmhkbOJxB+e4E085UKDtowJW4BSX4sXpj2Nu/Bc4/RtOfrv30og/BAPbonvpvI9iLFQgNsiYL6RdJCyZx31EjtJUtR1sTCKN7IMuWd0Y5Xv0+8YG7KDikKAlbv3fhICbXF2PP0moalz/HyNR/vO/gzotjHpseqrXufZmnSri92wGn/J7pu165rmqv0yKsn63KRApKYJBQgiM2ew73oe0nCJnu2hN+piLY+pSLxY0QsLubfLUOjNFz993t0S8VdZgNzR4+zTfnyzREXmr2qK83SY6tfr4GSaanJffc58WpuASxPEea1zIaYgTztLGtUEx4n9+aQ3WyjBgbwYIfbW/WeJtrpIckagAJ7IJTj7esMQOQqRfbzScKTlswOlSqxdYTBySQK38meiuwWMl6gCZzAzSbC412Wt0cpBOwD+5Eu0ZNb2FDoudruRADFgBOC6EtdsPx4U4Xjv23icZgcFreYHcPk23jUl4YnIuYP6VKdWN1d0+cU+S0/wwSAYsjZn6oQPq/RiGVhqPtwulYkOaiMN/tagW04Jpv3PJL3f10I0vU3gY4r0h0NWDvr1QUXOFsWBN1XRipsB1H6QnJO5lMkYt5Z5RTE0S7ugP1zGcz2gtibHQhMBFbHwpQE5rtusd+za4TwR50XNIBtLT9W6JdpbuVlBEEz6T9wgNgOj3p/MQfiep4GEcdPAsennNjRa+ecWmwTk4BbNuIJaDVoS5Ghz6Bx0tu2U58yA+U1DJp1AcrAUNdXK0lgxTsoPH53BkCoZDOTafKE+tzn/c5HzzRz18/DDHOdQj X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4354b7c1-8726-46ee-93a7-08dbc4527ff6 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 20:51:21.8350 (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: i7dITC8lMJNgvQ7637kznTPviKbCXida35qbWJp9b7AvqGSGzZdTQZoDJLbM13vcEt5JOX1rJ1d/3DjVvsJ9b8LpVprG3ExshECTa+k181w= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR10MB6794 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-03_18,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 malwarescore=0 adultscore=0 suspectscore=0 mlxlogscore=999 bulkscore=0 mlxscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310030158 X-Proofpoint-GUID: IxeN-RfX_p6DPCn-UmxodY8Wkh7CAaCi X-Proofpoint-ORIG-GUID: IxeN-RfX_p6DPCn-UmxodY8Wkh7CAaCi 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/sr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 07ef3db3d1a1..d093dd187b2f 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -177,7 +177,8 @@ static unsigned int sr_get_events(struct scsi_device *sdev) result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buf, sizeof(buf), SR_TIMEOUT, MAX_RETRIES, &exec_args); - if (scsi_sense_valid(&sshdr) && sshdr.sense_key == UNIT_ATTENTION) + if (result > 0 && scsi_sense_valid(&sshdr) && + sshdr.sense_key == UNIT_ATTENTION) return DISK_EVENT_MEDIA_CHANGE; if (result || be16_to_cpu(eh->data_len) < sizeof(*med))