From patchwork Wed Oct 4 21:00:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13409462 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 EB583E936E7 for ; Wed, 4 Oct 2023 21:00:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233808AbjJDVAg (ORCPT ); Wed, 4 Oct 2023 17:00:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233712AbjJDVAe (ORCPT ); Wed, 4 Oct 2023 17:00:34 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89D7CB8 for ; Wed, 4 Oct 2023 14:00:29 -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 394FIvas014490; Wed, 4 Oct 2023 21:00:22 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=HlDNIK81sJTU0CUuzmD7d6L96l01EMkXBd92haI/Y6Y=; b=KRKbHQpFQoHTqTeKF10xH81k6a2b9+0npMrPgn42uQGklsNoS+Ry27zfmsS7mEQmhSnu 15x81AH9TVZoUrhEMzdJ0PjgFCZc27xj4WFcs1DgzcPyPTuWdAtsRSal/aCbtAWjf8i5 tXFq+MxL0uceutSqh63CFs1+Ph6wSNVDikAdeN3utD0SA8GaM07RLpASlxS4IXKPUL9U Go9lnVAlV3vyR8pL5aaKSyVFB82Ot5dm1JjcrOW7UTkOYKRDyQRu/EvzeuvIyYYaiiu1 sq79nybcjeTdZNrenE7VqQoE1cC8jslo2bzUALUKZ6d1OAeFyTn0yns8eK6Vkw5Ok6Xv 7Q== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tea9283kn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:21 +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 394JYJA2003023; Wed, 4 Oct 2023 21:00:20 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2041.outbound.protection.outlook.com [104.47.66.41]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3tea4853sd-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jVL4o/tSiQ9bjCKzPL0W5J1GK9TC0CIlLFOMp/UFRDl2gffDIMBLxcYl2JueaOsOKJ/Uqn4/z98uvJMniCKhy/yTEGmzQR6Gmd9kIcAKHtjkcnEK/pz9ZSnffHBAlkotJdVg9OCRyM/+2+YpQQ6Vzht/8Oh4zjZDTK6mBQDHyYE14UmA8oke7e6Czjy//xn6sq1+UTHDy8fIqqCS6bjlKT8v3KB2AM6oqqnwusT6JFf4xV2TRPaT5eCCTtn6hqaSsXHjgpTD0CLvR93cAdXlPM8EG7Q28wWPZPEmPOdr0zw/Cf+T1TPqahGrlI1q9cTS17ZnrWKjyeh65Z5YVw7jeg== 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=HlDNIK81sJTU0CUuzmD7d6L96l01EMkXBd92haI/Y6Y=; b=Kgf7Qw6JsGIfFfYk2/58NN62ZQqRE/LRxa6x9AqPOgeDxaNoxTFE+PHBNJzJDMGC9J6aHPEkfuhDMBCjGLYzvLQl0wexnOTg8/GFW7rLW5bAaqE53V/azkeMvIwk+8KoNJ5G4dpc28+gpzhqoxHAFP3AWzQLIBkRTdTUZJAz/s6nKwQEAIWaNIyGHEZ7aAr3JKXkI6pTLiJe1dgiUsqwOBjTzUBhyVnQL6gKO3A+Ys1TuUDWBRxsh/aikPcq6XGMdaUV++th2khHEbN0soQc+VjKNJo21Dwf1KxjlPgScWmTaJvs8Q2tvsqLWcckaPFcChuyXn2Kx2osuPQi27dkrg== 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=HlDNIK81sJTU0CUuzmD7d6L96l01EMkXBd92haI/Y6Y=; b=ShixH0w8ASCgDDNFIKIsAiJ+es8a0YP45oowWUEfaC3wc2e7NS0wbLY1PxpmPV8xM3kONhxuqk/OdWKOxFPTtZ/p//v8OKrkCSJiehqM9INzHwV34L8FKM8KMzNGeiWeOkxu8sJbK2WjyP/u4dT9w7YGPIxzifNLO0NRHKhfjUk= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH3PR10MB7413.namprd10.prod.outlook.com (2603:10b6:610:154::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Wed, 4 Oct 2023 21:00:18 +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; Wed, 4 Oct 2023 21:00:18 +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 v2 01/12] scsi: sd: Fix sshdr use in read_capacity_16 Date: Wed, 4 Oct 2023 16:00:02 -0500 Message-Id: <20231004210013.5601-2-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com> References: <20231004210013.5601-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR02CA0166.namprd02.prod.outlook.com (2603:10b6:5:332::33) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH3PR10MB7413:EE_ X-MS-Office365-Filtering-Correlation-Id: 22a4d5e4-17a7-4100-9c59-08dbc51cea45 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jxdNjSvcxE8+eAbsWtcK+3sfF9Abve2ULoijMFVbvnMDTElP2XSYw2ANaD5YbaBZpBjYBQQsy35T3hYYv+eg3Ov9gg7QAaWNuesARHZEvhLSnKhJvNOhjsoosJTJ6bZlreb1aAirDf2OQiLiEHgrjnqTUwtb4q4TwHMAX/hXjoQYvM4hc6TxyQoMWopuaBkXLkb5lFohHBSDZ5XfbyU85fTKKX4YpwGaggpoBWTgAoxU+uXe79c7RPL3N6hYSXcbCQS4rpS3LHR2nZT+bf8ZJSp7T2CvIXeF95LAXiNUXbahoOpvwYLputMODNubV7Og9hJ2avzkHSdvdD4SWP6hjeudE7U7Caicb+4761mny5etEA0lBPhAM7FUZHfRauvPos/KJiKARNnGLfvWxc/FFkT9YdpNHPo4gUt3lAICCpcnFy3lgbSnYSCYZdUEaX/a25yi8+pEtGLUzcCV3DEuJghRnf3XZO3liRManLESgBA+1V1a7ZmusdybBBSrrsCsHBIch4eAA0SnzIV/+qu5RU2erHFJlYM5UvJ5vFnoBso= 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)(136003)(376002)(396003)(39860400002)(346002)(366004)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(6666004)(83380400001)(6486002)(6506007)(38100700002)(6512007)(2616005)(26005)(107886003)(1076003)(478600001)(86362001)(66476007)(316002)(66556008)(2906002)(66946007)(41300700001)(5660300002)(8936002)(36756003)(8676002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yAXGlCXH+TEQvXpuT7CCKhisWK2uC0VL6hTUnUJPiXyp7sji/SgOXPXxZrK06B2ijbilViggrAOTfRAyZx9otqx1XcKqb5D6krEt92KuIPm24wgb2fYU5jpNxmEepOVtyTZb/dHPhbh0GvtJwglrsaIOiYeKUvVdErbMrppjcmt4BDufl5FGLWhWLOrmHSF3wAyNNGK1qhdnM1zHX19pgB5iIgGiOHSsQQMURaG3YCX7rsZ+d6jPdhMCDdC2NGZnQkAXzP7LYaxAIlrMAW8fde9b/FKZgFmN3CVlFCWAUGOJKl2WfkRlq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PJ+fnJrswV63lZKU2PdhFrGUczsssYm5brEF9nPHDlPWJXC+nIsPML5hTOjd8IfX5ATS46XH02CLJ7Ql+iWrhCfdlM0t6srqcUnPPk8MGVH69QyX3eBYda+2iVANLAaAy6QwDNm X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22a4d5e4-17a7-4100-9c59-08dbc51cea45 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 21:00:18.4211 (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: HZ4B5Q0pIjfs5uWTVopy1x2hHkFJuabcAT5P/mUuiEkShuEVB9cPsgJxEf05ikexDsk4dhWP72jl46yCUr6DEbmgiEs75GMb0lrzfLuCvi0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7413 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-04_11,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-2310040155 X-Proofpoint-GUID: qUD4GTgb0Hl9a6gLgavHE9ej2PTb_rGF X-Proofpoint-ORIG-GUID: qUD4GTgb0Hl9a6gLgavHE9ej2PTb_rGF 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 83b6a3f3863b..0754949c9f55 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2435,11 +2435,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 Wed Oct 4 21:00:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13409461 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 B0239E936E6 for ; Wed, 4 Oct 2023 21:00:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233802AbjJDVAf (ORCPT ); Wed, 4 Oct 2023 17:00:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233557AbjJDVAe (ORCPT ); Wed, 4 Oct 2023 17:00:34 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF783BF for ; Wed, 4 Oct 2023 14:00:29 -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 394FIumn014794; Wed, 4 Oct 2023 21:00: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=fa3WxPQAbP5K94E5p+sk9eGKtVDRuxfIpoYNxUXqWzg=; b=Lyod6ArGnUiETevQp3yXN1iqC3FvJIH7dX+Vx54RPMMO1ro5NJ7DPEpd1vGDkwki7C67 8rFvc0xhd3mLzmPXKGHw2BgbC7BupgLNq+3S7wZsnAuCuKbwK/LoTVn0ow68d9OxeeSS ZYaV+0Lot+JCkCOOBRsWhpemtzo3Ns1FYOUCYPi6r85guqM3pojg5QH1tLJbifmGcAm1 Eu82S4pIbNKOXByDaISbfkmkvRaVA76igTeQoPRoaOi3Biu0tR8jHHtiqmP+rRpvUSgK f6JEq5iJJTC915Z8n/yCd7ORCKhnD9waAWq/QQeSvqCoJjgUe8Wp8xGWkja7q/7SYvrR TA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tec7vg0bc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:23 +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 394K0uLn008694; Wed, 4 Oct 2023 21:00:22 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2048.outbound.protection.outlook.com [104.47.66.48]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tea48p3gt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Wk89igw7/MH7puiQHIaIRKWHFfcd6w47H6MTHFioChHS71hav31I/SVyNfGp3hZr6WkE0YFir4NYdBYBtlLeRWMpPBL6xBLiuzDJZm6Y3omVELtGh5um4thcAD/SSsiIX/tmZ88h614csg+mjpNjlZ7KhL0YjkGebQBIMDDrhJVS1iwP/ouZtf81m4I9WSVBL6phpn9S+PWCbM4ln9N4HK0kdgTXpMJU7WVijwUuziN0DS3vNRP/SKobnVvpUIxx43mqjbavmnp/wrvloEEp1eJ0/0cMsZ0p/3EozFUmu/uYhfuAW6dOX7PqFJLSxSbGrJDIA5XOPQx/7kfNv2YFJQ== 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=fa3WxPQAbP5K94E5p+sk9eGKtVDRuxfIpoYNxUXqWzg=; b=Wl/J4ywXyoZVNN9PM3f3ENRUkL9vsrZisq/lX41Caqv/TZiXSvFn/7nam5+9mBGdgSWkhXskd5rE52YI3ohBgG7mHqbiNhApeoTjVME5vZmQuWZxXz9TfF1AQ/y+U27HIxLNaQcRWamwDjh8Jn9e4RjDumffFvk1pPdpi5u0Dgcllr0Mh6QjJd7tsg4nIelaLjXDawCIJHbXBfqu2tqJiFFtk7llP1/KTPjgbso6RhG9M8UIymXFzf0I3yGc++jliz+M8Dqo5BavCFZZk2dhz2CEE+IKWtzl884g7bmvaZZENLljbLin7y3NaOR7GKbRzhbABJ4rN13x0Z1swXGQXg== 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=fa3WxPQAbP5K94E5p+sk9eGKtVDRuxfIpoYNxUXqWzg=; b=tjqx9L2eJAhRbxT2M4JOxbCYeNa2BIK51C+oLAlLzi+TsibKL/xkZyXik50rCyzabbvzpAvXawJZAa/1IynGaUna4z47Bh7KZeL5Ydn7P7BH+awCHnNcTu0w/jZUri0JDBKtF/kewPnCUjnFGyFezlInNjphsFvdj+xJOXFuq8o= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH3PR10MB7413.namprd10.prod.outlook.com (2603:10b6:610:154::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Wed, 4 Oct 2023 21:00: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; Wed, 4 Oct 2023 21:00: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 v2 02/12] scsi: sd: Fix sshdr use in sd_spinup_disk Date: Wed, 4 Oct 2023 16:00:03 -0500 Message-Id: <20231004210013.5601-3-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com> References: <20231004210013.5601-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR08CA0028.namprd08.prod.outlook.com (2603:10b6:4:60::17) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH3PR10MB7413:EE_ X-MS-Office365-Filtering-Correlation-Id: 711f0046-19bc-47c0-5ce6-08dbc51ceb61 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nSEsIg6jipD4xMy9xC9Xf8w1JXLCsVeft8yKtoy+GhLxUqvKwRc2IdqRH+DFaXdFyrscsPojUORdIkhOCW2RAokXaNwmEn3HZl2RbF6ZD9sgyesnKeKYjE762hYr8p9MGOm6UspClGfh/jXGEe4rTGsgkMN8K7dWYtzaEYMyBRKutI6/7b0KLKZAcAonxCIbBATL2UX7c/EhZCOJv1sc29fLBcs+IDWeyWOl2SbrXxF52v+RNY96mBnhwBDew8ju5AUJ9JyHSpu+2gvRIynbtVFjPvfc9IEvlU/j5yGbnpjkg8eyAmEbYkpNvDquGS0JS54xgJmlMOXTgH6V2zmMNHS4MTzrVNbm19ktqN1rVYQExUV9+m1mLhiCijuJJiwIsEGzBZ5fA8HwnTygNmXIQz6Lp1Gz3KfKZl0LHsK+dNDiaAo9zwVo3rzm7luATnWHeaZ38mI1Yo2C4EZcQ+Sg8AsNkrVr1jKUyW6VsOV4hyDCRc9GEHyM/YBwEW1YhpMZHgOmKmKLnS3rSM7VJfnQZxyjIQdabMiVxbqSxUFhkeOXpCwQdzd2iDFZN3EPNYGk 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)(136003)(376002)(396003)(39860400002)(346002)(366004)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(6666004)(83380400001)(6486002)(6506007)(38100700002)(6512007)(2616005)(26005)(107886003)(1076003)(478600001)(86362001)(66476007)(316002)(66556008)(2906002)(66946007)(41300700001)(5660300002)(8936002)(36756003)(8676002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WX2VN1UPZqspt2m6KxSAJr6JIPRVTx9o1IdK8iuRJ5h6K4aAoL84PFT5J0iPhBd7INHnmuFE3EFphQyXkvD9/b/JeJcDsp8ddHlrNf6Y0ExYQu1/kviiH9EYh0BvIEq9j9eC7t/yOduvW/ldS1KRsSZJ3kaF0b5JbBAS9bDVnff8dc1IGqkfvYQnDgZuyBq4qUcDoqFCvg/nwe5t+oVYU3TnWKX1YV1TYw6pSprTCa9Hc8x25zrJ1VGJ8XOUddg05RxDZfbHC30JFVaGHJBzZW5v3GR2qOENNX0k22M71ZQbnTg8wcEWE1GEf9RMimYRtn6+tU889Nv1ygqWE1gpR3lhOMHhkJi8pydotZuNITFCP/nmxs+2P8F8bUtpwJTxQILDLxtJUmZSeToXv1iH0oxZ2ega8IBnJ3pGrgJrBce6s925EAQnzArtAW0H88tuiJAxTDNbSiD7FCxyFCXsHvhVUQXEBQeiLDVmHg+igfDBJ9zgG8o2zXjQm10iGbW77eHQjE7fQCFShnWoHvWGgy2sr9WkrCwYtWuiL/AZthesXRKDPcpNkvn1aRLaft8jIzWaJYYB1BpASZbL77VhFQryI/xLsYU/rs0Sf2jv4bFxz988ng+0GM7kGf7jdf5kvOpxx6UnBHCNuvm+gyYm+NENSUqXjqRql7ltrV32gKBmH0Q3pTWBP6ljyo2uKN1jdiwWsRaC8OHizz3Vn8AHSav3PIHNffqoXfqAi2eQMsWkionrxGgfg3VxUCRvCNBfvwaSZNjdybPHf2Q0Hm/UczFu9evgxBxYbxlJOo+q7mbTcq2/vE9gVJXWMhvlaUZddxtNMhw+NFLU6MKnH9FXrVoy2r/wROAZitB1hKeelnrPLeVGFQ8XW80VJWJ8TAcJIU4tLKiJczGJKwVSuqlkfwIxojgJoYP+MfLYR6Qo4h7+DF1DuIvcYgO5wxzqsN8anbNMBAjlRBCDHhx2XUO1GWHDdJ+OYcS7v44khPD3J6PzOf8zeYL1pDmEcFYCTWynAw1mH5lBWzvghGmjGg5aDab2PKg5kjRnKlNIWkd7Qptns+iUXQJLG4YnTfa495cKxLNKfaPG5JqFDiII3ce12HBn5i+sUiJ5C0CffTNIFGTJDGidh/95AbI0QKmUBCrFxku6mEnFKjiz3KBtdfvtFv5aNGd4rdT8IPEb/tjTXA86+bKLmdY0xpcw6K7bQyH4KWE9igIKdRAnpurnOzr/pb+IHoUC3rRDMd46/LsNEC283kU7mT93213KOC7XgVJxwXl7o0sGTLNI/QNODWFx8wjwiGI0qYgYnab7O81eSdSY4yowoZwQqgQsYNXs+lrlAyAXTtBLACoe33c6Df0J4A37D01PfEefFw07LC8WwHoeL4ugMr2s4+feTRGkChXabt1KR5JwRB17vitq3bQXpPBNVrMxK1JfH0BIr4luMElfoun1b1J8ZoogDV36h2g3Y1pPu7NUYA1NKMcxhjT6NzOL/8j7QhK9NQWHtDIDpgtCXDBA2kILpF5yYdIeqfzkq970S0zA2EcetOVIhfU5PzSA2QetRHdsiEIhj7QQ4ivLqff5Hi3BohiRQEwfS6fAdm3r64+Y0S5lzd4cAwvSSw== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 1mhzzUY9fsSFLEsv7sVbTgrnLQUBprFImrA6ofnowpzokHt42iXUJDSOBWXqLehrIIIH9poxe8p64eat8o5z2MIs0iANzvKGNggWz0bZs5EoES3a62ua5l04f3cBnR5zE7ci1u++Jq5HzJg5U77TCkXU+nwGVLz0fQra9uFW0vnkWsCSixyQJQpfZ1c/FP3EpcOMFPyLDjpEiylSdbn4XUgmSvWS3HktdbQF5Go/TmwBsnLj+M2OMeM/cC/kVHai2PWCriAM9S4ZKzDR07BlJZ0T8BKNGP8gNPbX7hN1uwmH7nDhZQMugQ8E2Od2ZqgAT/HmlzK4aZeKTfQFAieM5uKLet9tHdoKInWvbHejALw7zKygZuRXKPpQFhuNJ//07BIDHSOwuhxBxg0XclJH3n09uvGJEIN+zqFi5V51+ydcQU/eNtnXtsdzmdbuzK8se7LpwCUSSGcJyf3gTVR0/fn0FTYy+JG0VA1oDA7mnTXkJoNVXMgpg19azFVlseRSgsLT+3upKneaSxJjh3nso1v6bPX4Am7TkwxfQOHpZ9l8x3f1cT/00jylpwJUtg+ZlYVOV/w22PdaPI2Ul9QKL/3I3z9WEAZEwStHpi9kTKHvv8634A5xWbvxv4Nia7oU2rULMPI7spUW9M0OOUAj67/xPOXzd6mWFG4CquPpFCfpwlgLfTQxMlGIO9YbRn3t11uEHgZELprEmtBaLtljL0nDIiO9UXpQ8ea+dsqCp9fbJYkSPOvVd4M4ktHOSDmVQB/+KSETF5eP/Q+OhWRum/b7XIV/Nu/eXzgLD7YgovM+N9r4TB6Q3QjPMyzt+li+ju1sz9czAKWbYSPu2k8tJkoLbCg8p7ingdVXjuDNy4AE3QcPKjVL6xR+UOlR/VF2 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 711f0046-19bc-47c0-5ce6-08dbc51ceb61 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 21:00:20.2687 (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: Zr45nYGDN48lxQb0o4T05B2C8XgCzI7oFPT2ML8fbHLvzGBKYjAGyHOMyCucCZ/17yXJK58SQEZBy2oDBNmT44U1eEcYq5q+2cBCrvIIyo8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7413 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-04_11,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-2310040155 X-Proofpoint-ORIG-GUID: HTaegyL7yDrVPhg5qYRtyG0cfjWW0VYt X-Proofpoint-GUID: HTaegyL7yDrVPhg5qYRtyG0cfjWW0VYt 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 0754949c9f55..6e306fe8cb5a 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2227,19 +2227,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 Wed Oct 4 21:00:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13409467 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 74071E936E8 for ; Wed, 4 Oct 2023 21:02:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243986AbjJDVCq (ORCPT ); Wed, 4 Oct 2023 17:02:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243999AbjJDVCn (ORCPT ); Wed, 4 Oct 2023 17:02:43 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73F0AF1 for ; Wed, 4 Oct 2023 14:02:39 -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 394FJ9vQ016140; Wed, 4 Oct 2023 21:00:29 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=OvZyQY9iYt9c0aeH6KuUpSX7Qfnv8Z5DJb4b6SYXIFnJdZcoadK53Xjtrgo2mc3MsluR d3I4EqOhR6RGyFdneNfZzI290dNmuoYD48UAXsv7j2j3TETPX3NNBCIuHDwqvda8C0dC UUCqCfXfa/avtK1qzQ9leudChKtGYeBrfivAjlpKX6EKO3RZUjpVwjfMlHY3g0GiYxEQ 9qfP4gCCJ8HU92xEBqIi5b88F8fLcnaFDSbrK0iVnrr4G+kPxKO0FI90yTPRk1JC31oR FRiCkd9mVxrZjGJnZdLMQg4C7HFsgB3PhPJccR1qFotT3xYyEs90aFW79r4YIk8do00Q qA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3teakcg4r5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:28 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 394K2gw2005824; Wed, 4 Oct 2023 21:00:28 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tea4869j4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gJ7MFkyUiV1XEP0p3XuKRy6kHLv1rjgPGUDx1Xv6cjuepCaaMxXGi23pa6A8k/EJW+wHedIM17dI48wizz7dNo+kEnccf7SLXiyx06y5lr3NN13tsrNoQ5ua0uUYXQ9ErUBgzYM/6K2fiksgdce5iTOtx7xPZgl6ieayQ8fJ/1qlhmU3fF5QJOZsV4/Y16Uq1DzcafYz0oKyoxzFXIrIqoK6BcBnk80H6+CKo1RkGjHiRu5ejuyO8jjWQfodtQDCgxBN8seEKY5qtaTmlk/hCZArt2JcD9UqySTmXS9/ZM77bEPg83CbgPLQ7913W7lOYO/6lFeR1zJpIoD2Vl1r9g== 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=GmfbZKaDbEHv7NCy8cwnQSN9jY2MQr9RTzbAwUvyKHosvGNpzA68A3Qw9HR3I2BVqNEIHnZJYuYq9UbIz+rvyBVl7HBzAxQl6+EXOvwLRMVbxld7glKFxW+/uYutRDHZ72ZoUSlz1i38SpcocC3zid4R66RqDwdipvahV0px1x5NyU97UZMS+mtjCqWLYeaXeHKrcW/5YxNnHHFZfisDLu1mnCpHHSrolteVGXL5JAXcyXBPZkcb+fqD+sHfj5QoSsE4Giye7LunQ7sFOg4wm34BAcQlX95cJyDXr8DuZRasiU6CENRPhOWTAZiX2fpICLV5nruL73jRiXjaX+TzdQ== 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=RET8VPgYjgKWpmifeWPgu9u1y0LN1DsP0oQ/30oM/upHqAcSM5pOacw747+RPVXLv8eoipkjbmo+Uaq0s+mIXsUc4a03h0FWK3o1M74/XTBuFF99QFh40I9R6NV0ZKeAGG2muAW9E4SKvh7ILKF/TMdJ8Mybh00dr2OkIyP4os0= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH3PR10MB7413.namprd10.prod.outlook.com (2603:10b6:610:154::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Wed, 4 Oct 2023 21:00: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; Wed, 4 Oct 2023 21:00: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 v2 03/12] scsi: hp_sw: Fix sshdr use Date: Wed, 4 Oct 2023 16:00:04 -0500 Message-Id: <20231004210013.5601-4-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com> References: <20231004210013.5601-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR02CA0153.namprd02.prod.outlook.com (2603:10b6:5:332::20) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH3PR10MB7413:EE_ X-MS-Office365-Filtering-Correlation-Id: 2f54e56f-70df-4e9d-e2fa-08dbc51cec43 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gKOltC/2kt6PQpIaPEs2sgW0qSo6kjrqYMLx4U60kXlWDRk/4cbWN1os0DkXLRsi3YwckBU6CK4QU3PYP8xqG/IykT7KZBFI4GuysiLOsak2yf+13U1oEOIc9r3je9pI0fYOPf7NES9QkYrAIl8m3jlzwEhAPtlYFrxxmUhzdKdMglHFOoU4t7Kl12zEX0y4jFuulapHochslB241Q06gec6aooPhyhMWGb5XD5pREs/hgO/vgzKFPVT4s8HkjE7zrTi4OjLQfme0/gRWjM8vaiGfGDByOvg1LdZEd14JS4P80425Zm2NBkNZocop5nzk2NhbqPv8WkQV1HG4d1unCySVbschTWVfWXtQgB2b1qCiCgJxteuIpDLUohsnPTNCFepdSfVfs41UoumT7/4EGnsqDLh4+TD2VAlkCibrEZwRvkvBdMaeopgXod5SRSFje9SyZlsdJUPcEU3zDWn2us3yP8ikNA9xmFsjtuB4tuGSNJrStwXUtcH+KlcTznVYD8wwl7SqRdswSz4q5OOt4t3t6uW4hXafuChuxSU88Cw50nFx9H0U68eUZpPeOyw 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)(136003)(376002)(396003)(39860400002)(346002)(366004)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(6666004)(83380400001)(6486002)(6506007)(38100700002)(6512007)(2616005)(26005)(107886003)(1076003)(478600001)(86362001)(66476007)(316002)(66556008)(2906002)(66946007)(41300700001)(5660300002)(8936002)(36756003)(8676002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dV/OCx5XKXKNaB6OT6G7O5MBnKCkjSEJzA1IezIA0tQvm8YnfQCkcoQoLuWAVv2yIObwv8rF+K0cwRD0TEBlIE04BYvuQf75zOhz+7Vii6E2ShIaPd2ZBZoN5sNgs24FIaDEuP//FO/b0kScjmYfBcdoRrPRGq61Pe0Hve+X+P6yR29P9c/aZhYp2Ctnq8Hc0ehSHttD3UMMGnmlZZgn0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Udj1/Q9J4+UYKruSF78rqPD/dUXlzIs6DJACgo+Ib3oRsGIyY6qVYgnO3TdHJMVQBAdHpTZOONPOHRzq6Kz2MJxum+ZKiyDsoxVXPDMHzlGnYIx6o+Hvvl3HEBxZtFFkCNtuz7ZWKGj43snY3bpHVaL3XgUOvSxU1ZpOneUmtVHatsrNMa9of75aXgyLa46+BkYSudC+GUhiDONGqhOjzhRnK1H1SF+g5fUY3xwaROEHB6/HNUv X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2f54e56f-70df-4e9d-e2fa-08dbc51cec43 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 21:00:21.7885 (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: LCqVWWs2gJK0HKu1M6smRxO7sNA78HCR30zFWDr3OpyQg23fiuH0RNNRSTRDB1Q2fy1UAewB+/96DRdTFQRKdeTYPz6oCxJxuKGNowg71xM= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7413 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-04_11,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310040155 X-Proofpoint-GUID: wVP3qcjCUUq7ocB0wMmfJ1-kBDAJ3_HC X-Proofpoint-ORIG-GUID: wVP3qcjCUUq7ocB0wMmfJ1-kBDAJ3_HC 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 Wed Oct 4 21:00:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13409465 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 BF592E936E7 for ; Wed, 4 Oct 2023 21:02:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243933AbjJDVCo (ORCPT ); Wed, 4 Oct 2023 17:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243989AbjJDVCn (ORCPT ); Wed, 4 Oct 2023 17:02:43 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3EFDBEB for ; Wed, 4 Oct 2023 14:02:38 -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 394FIwZj014504; Wed, 4 Oct 2023 21:00:30 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=UUPQYnUZH9Lawh7LRpcH3H1nJlrQLCyGo4c2mBj9nokRU3kA28lO5bkJVOdU931VP/Hq nBSrocyLcRbGCeAR67w8Leswt4hJIYlbZMjREFDSUsT1CUCaoWm3nOwVu3rNQzcunJIW EnC0sl2jFTQ8KMKyxE4gSgGk3Nh3y4CD6+wdiRjVcMe11dNA+LCI5fkbYcTbmJhFOWOG upoNyYPV+fL9XMnU4NpLcxqAz3+eSgvpK5WY6HeP5pV+Vnb+soeCxpElkecej2cbRlX+ Xy3wmG9x/z4ZZudPTFQYeGtq1DQVBmwuR4Sgu+RBHT78zEoFnsXTI5VPESCqmEkozG5x FA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tea9283m4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:29 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 394K2gw3005824; Wed, 4 Oct 2023 21:00:28 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tea4869j4-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mqstWbxYob1Oae6OjQGMeSLdm999NoSrVeKiPx4JrOZ6AEacWrX80Zs2U9EYvx6ZfKRSiBLI+aac2r/qCgjj+eI9BwCR7hFEz5hceR6R8PMlKsYsaIrSJfEeJ/pMSdop4kdRUXTJ/7RKZ/CuzcpZs++m3Hyu1eZQgJVtVvEfI8nJqLO8oEcV1NaLHx287DRWG2gckm6YfGIo04buyT86/Hi9VYeA6/ByItmtmubDVXIadzBYDqZxnQ/l05W2vjs0JbGsZRtyTWW+n0ZJL++HyUhii2ouddtr7JDlZVFrokFxBegLZucE/39NJoX7P6vFRDJ286equ6AntI7ANMa7jg== 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=hyHqZ/cMNzRS2dPN724zDylBvzTf4BbSI2WhZLNXVYw8JG8/zrgSU/bZG7rMSCoZZx5NpEefnTMhAQkJfxncMsy952DztDmuYl5f3kxmH/6ktlzr+cecwRleGTmVciuAa8qY7uHRiOzv+ClR5qGbMlbuVW9D3x5D+rr3bhiXG1LKvqZg1dx4RpjT0aLqOMhEIc+3KSPQkRbKfc0SY6tL468vrfXtmxAkSr4B71vVdMx/otxdwfPIAW3aQqfljJgn0dPLRhs0Ino4/Auetmyx2yeySXYGdJYwNIJr2EUaViDLqRo+rObEIGvL4phMikZEEWIQoX8tdXh3TYJa9OIXxA== 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=blTDZdv8WytMAn+w9Tl891J8WH5Tuq+4PvhwGQpGz1dvABUx5RI0F4PsaJGdTlhftu7i37wfp729RlGbJ7WIuU/UTIABMTGIgGuHoy6rXQ3h5/IUOxkaI71rd+w27iwnuutcLEaXEQgDlIfUYDBH81G+5QYU2NTEeg3fYPUU+QQ= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH3PR10MB7413.namprd10.prod.outlook.com (2603:10b6:610:154::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Wed, 4 Oct 2023 21:00:24 +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; Wed, 4 Oct 2023 21:00:24 +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 v2 04/12] scsi: rdac: Fix send_mode_select retry handling Date: Wed, 4 Oct 2023 16:00:05 -0500 Message-Id: <20231004210013.5601-5-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com> References: <20231004210013.5601-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0172.namprd03.prod.outlook.com (2603:10b6:5:3b2::27) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH3PR10MB7413:EE_ X-MS-Office365-Filtering-Correlation-Id: 390c2905-4206-4697-c93f-08dbc51cedc3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Sm6ccKXemx1l1Tx50ODg20lIodNEPlbRBPTHQpnUFxgJ9mnDOGy6G4vLUW6KhkI22lCkg73x1CH+r+vV9IOowvqVWU9MvdKFH8BEg33KzqhmvLdLAHkvDEBibTli5W5lS44PX43RSh5jPUu8AySHB3BIKQNgqXQxVircMw2NC3gcRDXnDUKBXczT+GWOfTd0AEcP/8Sxs1qvbhcOrMqSq2cSBjdhjI11YKk7n89+vqWzZYgKThfGBD8rV+0UoApORkSFi1UhUUMIcoAa5unjThDA3asch4/v6fP4E6yP2JgiDsZoCOuqPhqwIe75tz/RQ+t/jQCBNoRH2/5BGy740/pCtWFYCjGSf5VuIoWKFzERCS7s6LY6uDJqerf57CFvGHahUqKDhpMoG9aiXkDHNKXfhuLvhk58PCuH09xKPBsZEGSC2kqaJ0Oi0wKO2ZIRYF2f2mNczngQLVC8gV4CYKln2zoTsNOP7te1upxH+iJlHwqRyFLvSEczE5OpEDYKV1+IuQtBdqcIz8rusKCv+y+nNdU8fhBXaWFEremP+7e7K0YsgektAWvBoe4FBBHx 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)(136003)(376002)(396003)(39860400002)(346002)(366004)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(6666004)(83380400001)(6486002)(6506007)(38100700002)(6512007)(2616005)(26005)(107886003)(1076003)(478600001)(86362001)(66476007)(316002)(66556008)(2906002)(66946007)(41300700001)(5660300002)(8936002)(36756003)(8676002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /v8uarNv+2SQO/Q6BaYutIprW818rwlnxcMfrSimMzq5BXQcsYn//ytLc+lSZr0pQl59KoHKVNB18TIMvj+G+6+sc8u7gVKsH/tUXBlSc6MSIsgGll1GCeFQtiyb+SSP+G+l2sExtMFM3vVPopSJftqAmqT3JzMHeByoyq/7E2go0982J0FxHwV4N9OZGJMvDIGakp1o6NtLC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WGlkzGBnTGfB8q9cXDR0a93y6XqtEMjyiIjjQfHrexDUcUlP7PROdTBpLSKDi8/ChQMkMlBY+8+wAhgTUyEQPEd07MB1s0BQ8f2IAG3N+hmj15MLFKoFrT34upIAplsD3yh9vuKtU9E/jKgbVLrKyQQyG5k3hUP8i6ZCzBUGAagqpT5y0LCcCE3jLoeTEZXVJKmCKJmSyg4WRyP/9NwDW6fEBzhes X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 390c2905-4206-4697-c93f-08dbc51cedc3 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 21:00:24.3149 (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: jQlori2m5vBMNQ5jztiNjtPGqgA1s5FppsKemPc4JM20VEx/0cakAzYU2bQpNAo8gEUJX3kDnj6ihjFhqm7XjIHlPgLJKdN+E6zgnJTijPg= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7413 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-04_11,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310040155 X-Proofpoint-GUID: up91wf5HeCiWzx9OxZuSVRJYj7IdLZ8R X-Proofpoint-ORIG-GUID: up91wf5HeCiWzx9OxZuSVRJYj7IdLZ8R 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 Wed Oct 4 21:00:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13409464 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 3FEA3E936E6 for ; Wed, 4 Oct 2023 21:02:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243932AbjJDVCo (ORCPT ); Wed, 4 Oct 2023 17:02:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243986AbjJDVCn (ORCPT ); Wed, 4 Oct 2023 17:02:43 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B63E0DD for ; Wed, 4 Oct 2023 14:02:37 -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 394FIxcW027949; Wed, 4 Oct 2023 21:00:30 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=G/hF9uTI+toHiM3ybp5lSBU82O2qtZEsM+7MR0Ap6Hfnik1h00VewxgEmjPPd7UWAJVA eofrKzsg5ggpnITK9pfwp33xpjlBljZQeLn07cVRK78VvqUuPXy1mz9MyD1VRuxd2ldY o37UDU8lP36QonG3G9Vu7E3htZPFpkQzJSjalj8y99DU/nsejsTwkkXflBsFOcG5hCsg s9NNdSt1GABStaggCTS/7FzYdioFQBSRshAzqBrRzQU0mOPPtpDAwbbt9ErodLuDzeU2 mSinkNsVMm965mK4ZrXF37vu1f8ehZq11daighW7dkVxSSSdm7Y43kuFEBEx2hN4Nm4+ Ng== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tebjbyyd5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:29 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 394K2gw4005824; Wed, 4 Oct 2023 21:00:29 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tea4869j4-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bq7usmchvUBphQwsSw4u/i223qLnoh18k+qrY3q2M1kk7xn/rVdcKnTJ0vB1D8Ypm64tA772wK3tTLs48R9fE4K0s0j3sA4BApI138sOJBKDOhGx3FVbc3TfKMrVOgluBDl87lCyG3k/3lNZY8oBmoyo4GpylHjXvXGZRm2VJdYpIWTwXDqa94ytyK76XgTvFZXrTqWnyFnWc/QqaVtN6uX4tCRBa5Xv5GV50ox/wSXL92Dn5/cMS685Po9wna1PK9CuovVLNO4DZlytQLz8IhAjZc4QFTpgbxASdadDjlOUQB1rEDDRoCsvWGgMAlvANMVA8+sxOXrpsnGsoK6ilw== 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=YS2Fsjn837m3b1I8S3nSxEqXUDaB6+6CWc9yA3M5UeP+Z1njROJwNWYqMifWw+a7ccPL3YK4CijlKOaOU3KNVPOT8DfMZcG5L+Am/7c8EMRECRJBkeky0HdMJ6lYP04yHKwdjd2cVINNjbIO9Mc4orkPea1ZtylHj+hip74To4fvqfYYP5stI5OZLOagaikSbvTByYg7cBb4H8ERqBu9NDN043wKk6SAWnDiNAwDQpjY/DvsqpT2EmfYaa/gZCvXqFslck8rosVfSPqGoiQyZPENWCKR0liV2nHqqsfZk547tB89Gu4/fjgbFCHzvjQwvn0mOLqoRPItPhjvy4mlhQ== 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=Wq7lXtlMlq3NWNhjeuBHxHrMS289+xkV7m6AQi8oriOgxJcUgiuMLSIROq9fEE6XHBJiYhX3Etf4mBAq+trVy0evFaKz5YQ3/j08XkxLtt7I0tbrsd1Ivx3HdtPPhZFgHguWqU9P9UYpoEl+y/r5t5TVIsVtaQGEPwFurWD305o= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH3PR10MB7413.namprd10.prod.outlook.com (2603:10b6:610:154::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Wed, 4 Oct 2023 21:00:25 +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; Wed, 4 Oct 2023 21:00:25 +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 v2 05/12] scsi: rdac: Fix sshdr use Date: Wed, 4 Oct 2023 16:00:06 -0500 Message-Id: <20231004210013.5601-6-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com> References: <20231004210013.5601-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR08CA0027.namprd08.prod.outlook.com (2603:10b6:4:60::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_|CH3PR10MB7413:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e925813-b0b4-4d59-3b69-08dbc51ceeb2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dmsWbvEg6oUNK33aRXah+e28Wu1M67rP0TDqKdANKXbgrtnwNkRneMsQSl029s1ccHZen5lbs+RCjmQH3oCpXgWjIbhMJVgVAGyMNMoFIf965xTM1kjQkV7UqgpnI6dh/P+un3Nrvw3Vm1UaWCsAyiJdck+iGLw4MPgYLQ5/FVh8QBP5qLYr8EN9ULwsEMzq3EOiWFKiEWb1fGpiO6fIErUGOWrFstdYwgUxnVYoYnnED/wm2WfaXH/DD4P1y0ydtfAZ5yhvg29pK3rC6v88xjk9qS0yklaZylJZp0XJNQE4tqTaU/5rN0MXLl0iRDc2YrXNnmflKDsGhWAj2wzZ4uE+f4w5KBQa3knyLG3xsLYgQq1U90Lm+WDtvkbHxuUJKVpR4INZ9VF4HJpIfP3ye2zVa4VTGUow5gfqbHHj1Pj6dhnCDsftiHjqLMZwksrViGnluJs11tUKhdufBpG8HAqDZxrDBpf3rbyEXlsHPvSXSnNT4Xvt26PcOXgB5VqyLLOKOE7IcdgaGkftx6N9yuUQz4Y/WnLaYtda17+cMy2D88n1yFLDu1luT9jQ3Ufb 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)(136003)(376002)(396003)(39860400002)(346002)(366004)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(6666004)(83380400001)(6486002)(6506007)(38100700002)(6512007)(2616005)(26005)(107886003)(1076003)(478600001)(86362001)(66476007)(316002)(66556008)(2906002)(66946007)(41300700001)(5660300002)(8936002)(36756003)(8676002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rTlsdNriT9Z7NltXBqquPtmVIHv8F77uim5N1joeDhL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F6H1hxRbwR5LSnWMchWJt3GmDAN+TiON4gfucbzUSeWjl2PJmr/NOL+gCPKC0ed52rOC3+ymFm0+Pb61HqqfXiAQ6Zcqc1q3coyCf/Z3VvegiLeiHtubgzHe1xYsrdvUvaLdI/NviccYpt7oumgruswdIDWyJCi5oi5Nir7rtv1TAXfuY2YRtYbFq2Rd3ZOvJWvSMbwauwW1uF02kLpH7ie/HmmfSDf/K28BFwokvFGRm3inhHKkZNxErmO4ImuIjlvzrRLccnqATg3Ry2WQxaaZw6C7GzUf9v7nbqFERgT3S+sXOg3o4B7igy6HXxcVG12CLnXkzqqiS0R28HEESVS0NIWtnZ+FqfHSnixQ27bJVSY7iS/A9f8KEKGSPI+bnwcuUmuwLzCuvYb X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e925813-b0b4-4d59-3b69-08dbc51ceeb2 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 21:00:25.8286 (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: EOJX90qKJe4IdGyWier34CEdnexCYJa4T/ss8HTNqERfbrMBWU5LJJ5ehKKn+hTO/HebK/l6vzc4eVlp9R9fP111rUnh3KkM4Cn75s6Ef/Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7413 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-04_11,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310040155 X-Proofpoint-GUID: h5ghPqqOsqm5gq8Og1Y4UqtYofghgh1E X-Proofpoint-ORIG-GUID: h5ghPqqOsqm5gq8Og1Y4UqtYofghgh1E 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 Reviewed-by: Bart Van Assche --- 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 Wed Oct 4 21:00:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13409466 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 117DAE936E6 for ; Wed, 4 Oct 2023 21:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243992AbjJDVCq (ORCPT ); Wed, 4 Oct 2023 17:02:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43300 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243898AbjJDVCn (ORCPT ); Wed, 4 Oct 2023 17:02:43 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0AEB9E for ; Wed, 4 Oct 2023 14:02:40 -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 394FJ1PR016039; Wed, 4 Oct 2023 21:00:30 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=LWUYphiLIsqkLHT4oNOidBJ+lN49OMJPV6lJJ+vnjwxXC7up6ypaXd5KwzxuLB7DvISX XFGlUYeKE2/eLJNmV8BeKS6t1Cm5a5+vmlS6u9gieRmlVr05Yrs3F3nBU3Ctsme2Sk+y a2BsdCvli0HxDkOTrhn9NYc7iMnSGGi+uNuyOqeUrGc6ZyVGY+2djqvxcWvH8Esxl3Rw fVUYoCHiL2rhwCQV5Va2m7QwwLXsKQ3Bo62uXkB5jh5nqp29xUJd+TKixQ3/g0sfikW9 ibGb+mFQRJ1H2fwmG9oiV27fQNnZFoiZ0Mpu8Zcn+a0qO9QR+rNLQ+2wBh8BHXS8noAy YA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3teakcg4r8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:30 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 394K2gw5005824; Wed, 4 Oct 2023 21:00:29 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tea4869j4-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=clVc5rc/K90sSb/p5d9Tv9/kVIvi7HFxMyfYslet7W48mSPhV10BVHD0iQPn7SrXiXwitKx4p6JeqQZajES5w//QeGUkyciLSNgr4fJ0f2JjgSYICvXb3ArIel1584gd58v6rVSlGzpFCVB8YlgHIUOWxJY49OPdmxYjFIBFXBZ241vTxppVSih2rh6CtwvcqPH+0hHfo3fYRHNjBq2igookm1my9h4oic9XdhaDNJXK37cLjvsE/hyCx5aJ40xyqppW9C9qiSyAdSJ9FWm9aQ0hB3j50oNgVIuVmJJWwRDkS7qlmZdxpDKpcHj4tQ1WmChLfk/sggXMN17BElG4Mw== 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=JyTwV0CX1qW+ZWhJUqgbIzXN7zDiXqujZaOQDSNS7rBEV6233ExXrvjx3RGiI0r2vj0f93FfFNaoNWp5ADLYfipnJ0LkmUorTIi5qBgTYgFebCDyqpSC+WpWMPkohlJWolxra73Thmin/6rimRT4UhIl6WsHeqQTp0yd6XlSCROyRrt9r2IYfBW2bvlZuOktiNPWR+/BvzfVJV9cP3ld5rAsIpbbt7O14PfXH+iZVTys/7XlKKmO3haKhNAbKKsFV5a43Q9UqhsyMeYnj0B7LK+SGjRfQmnShyoCAEcj6PSUJcSBk9E7MfTFZGFZBax36xN7awof+Dl6ZMRuC3g7kA== 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=VeYnbfwoO4M08KBNDnQOky0/5mC7Yl77LIjQm0f+jbHdGgqFbZiRmCV6kRvZMYLPi31ZniJXNZHWAcM1RmrSijWoKX6lvQ6s72mCznd/V7lcvVWbRm60iZEgcZ3Mw19XuG+3FH0NE2N+tHsqOs3zPS9yp9Glfh0GejRcqa7edFU= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH3PR10MB7413.namprd10.prod.outlook.com (2603:10b6:610:154::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Wed, 4 Oct 2023 21:00:27 +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; Wed, 4 Oct 2023 21:00:27 +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 v2 06/12] scsi: spi: Fix sshdr use Date: Wed, 4 Oct 2023 16:00:07 -0500 Message-Id: <20231004210013.5601-7-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com> References: <20231004210013.5601-1-michael.christie@oracle.com> X-ClientProxiedBy: DM5PR08CA0035.namprd08.prod.outlook.com (2603:10b6:4:60::24) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH3PR10MB7413:EE_ X-MS-Office365-Filtering-Correlation-Id: 4bd298cb-9360-46a6-d494-08dbc51cefc6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gt1BkDVULZJXYpE/k6bEj/vSQE+HdYVEblbQNjLJovGLM10w+pWu1J3AMEWDdShJX3ehslH2fqNSMT2L8r5/tEi6NzpRC9dlxN9Js277CO/MSV+hcdHngwCQfrFPB+z+Gm4TAJSS4ZXKqJgeKr8RK56jlNhWlxTr7Jf+vkEbcnCav+83s5PQyU/xxEYFxQJUtJBbHhn7hUkd437IFghRTXORObD4tPm/ndSuuycPfqHfSy7Z8T7uaGX1nFSGAXBzVGkUBOcvbZQ5guS3A6n/KFfpIe/P+Vjii6KAiYkC8R+QVvWMqcWUFEZDJPfEA6ExLAMo6Tevb/Z2Bu1s01lDK0ifqKJLKEEAf0JKUWGSC+vF5/0e/gATffsShgHalP8RfTb/lX6OJKmpnGF5sI5uC3wumsQJfMiObSuARWsCYOd9xQLHBzbm4FQSHYuiNTwh8ZA8AB9k4pnpN43VLaHqyg0OJL0ayHgJ5CJ/+W95+Aiu2w094hGNDuWVF/osjhKt7cQ51RZCCo05Rtm1/ybb37FggZkbNGxfMbNQpvGNr0/WvxU1HFBHtoeQLc/2L7AK 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)(136003)(376002)(396003)(39860400002)(346002)(366004)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(6666004)(83380400001)(6486002)(6506007)(38100700002)(6512007)(2616005)(26005)(107886003)(1076003)(478600001)(86362001)(66476007)(316002)(66556008)(2906002)(66946007)(41300700001)(5660300002)(8936002)(36756003)(8676002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 8N/yxFHfiDMJm75lMWFPlvN7aK7iKMM/nOYJg7tM2YY+/9MQd6R2wEOTs7wVAHL/5IldrEmVqiLGSODYUD7aws+C2Z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XSauX/I0fgJDzLqlSrC6CJDBC5DKL7uL5BsUQC/tgoRkzlgnRkCH66pOU/lmP5DhyK909ET0FFzqA6XpVALIkTliQ+qqu7/304OhkShZxY83GgeaFj/u8a5u9nsdIbZP9ruyK89/BB1J0gmVUzwvhXBUh+/thwHxILicAut3t1/n/GlkpkU07SGQ1aZk13xXWQul3dILIEVwKGqNEHlze4h+K4Ap2DfneXXMjfB8qfcmlsHrjCSWz8qkJ67M6sipe07OZ5mI8zjPlX517FbYhNZIsOHXL5i98nhdZDWZ+1Fpf0gApYxWrPgPqIxRCzJHNoeVRYJm8C7+P/zlssSvYn85CcQzY8qozprLWM6uiXCr/2zZQ13FZ5CR0SEHTsLYPHHI4DBKEpfNwLSS2V7M8VRrDeCULGxpp0dWfJL7JTDrBfqyFYijtzYpPD29LZ5N4O6izYqMA74FQ== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: vASPXsOHhwN9WJHZpPaLI/T/RZMCvmvSZLyIsrBhxqlxv6EyWaCHqmgFA7nnS4mRBUmdU0HWVCioPhi+oD6WlMybPl1DefMLJOsZpU90WlucRwYvUV5q5qh4/6qCi2yoAlTrqL98J+TBhZRrTGIxWqWBIRafXNFAOclZdVXYEP047Su7iFb71tf3e/yU+pTbQtkXFy80CjF4AV065/3rZbP7Hw3e2DO3d2eZWnlgHT4BIoJOK/Wj+O/USI/7+XQEXCFfxZDvgKA0HV4+yeJbvdkzv8lWr1+gaxiuYqSHpnoelHHWquBkwvMNRI4h56vIYjllapHEfb202kgyfV2uBRLpHAw9ENqq63qsOnC2VGiVVZLtgxIdhsSrm6VyuYUq58gB5jTNpsA3pSABLPtY+dauVHvMwuMsWCQmOOyCK5QSnooi7SELm8y9V1nBBqW2VXy4vBLYstQkdMdbTQN21RvwWaENIH0Fjwly7YuJkurEQYqImEzTNiFiiPwt3sFOb7G5R9dCodn8NW9Pc4ouPZrDWhnFD16yGR88w3K0bN6K64v8HiheVne0Gz2thkMAtNRrv+0RyB1IiQvla2EiesvEkYAC3CuFpS/hx0ouRABMkwVzxEHpCrogCiY7pC5xHE8LdR2H3auD0AXTYAf445YfBTxRI8lhm24GzK/VxxxzFg5LoYOwxZ0I8DfIYrJiIVyHNUDnZQiB8rXy7ou0oLzOa6AV8JdY8f+5ja+HcNFfQHnwklw1uMPQd/UnV39IeMWLvWf5hPjtq5ibW96UL9uzBAgI5c/tSUo4rnH7fom6KYih6tf75k3BLlNP7+MFjgiHU4kVImcPw6IFnf1kHA6zyfAgG5brgwq/uex0oPZrlfG52RHp1SIMaO11zYxO X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4bd298cb-9360-46a6-d494-08dbc51cefc6 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 21:00:27.6591 (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: gv1CP05lhwtn0tqmmFQpAMKk5zqZZt3gkDQLEpTqTjyhIyeVRwHK0KThErkXLk7T0LRkpeho+HggGOMsU0bD5oaed6j0brE9oCAo4023UR8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7413 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-04_11,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 spamscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310040155 X-Proofpoint-GUID: 8CWVx5z1rGOa-0K1JBbexARvjJcib5hv X-Proofpoint-ORIG-GUID: 8CWVx5z1rGOa-0K1JBbexARvjJcib5hv 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 Wed Oct 4 21:00:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13409471 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 3545FE936E8 for ; Wed, 4 Oct 2023 21:02:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243974AbjJDVC7 (ORCPT ); Wed, 4 Oct 2023 17:02:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243898AbjJDVCx (ORCPT ); Wed, 4 Oct 2023 17:02:53 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6701CFB for ; Wed, 4 Oct 2023 14:02:46 -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 394FJ0jC014856; Wed, 4 Oct 2023 21:00:38 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=o0MJR3MGYLY/0dELN1iGZSmHDYSeiZaeJq1jeiZ/M+M=; b=Qkcvdk76v6qIQXNndmZ/bFbSO5LP5JM7o8C6y0dQe629/RxLIlsQAry8otr56iYv7kT+ BHuWmiPj+z1Xn+3Ck3MCS0eQnkvbYJBmd08TtxKs8uzuMk6CXmaO3wcfQCj6zWlpVDOV gMQYHoQ8klwbpgfmJT77x2W5Wma1aFpgH24VsldYIa4U0OV1MsqqyHQTfgV4Vwk4gyTY MHVjRQyNWi0fxONtPaUcy8Mzp/drP2QFmmP2jVHpLXGV5urw21m44HqpDN/cyphUqfow GaT9h/DtlJ3dhqbAeqrSPZ+/z5WP0X1hCVNU7ixag1kkIaOQWHzh7daxpKSY/Tj8ePMD ZA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tec7vg0cc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:38 +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 394JbOfb009654; Wed, 4 Oct 2023 21:00:36 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2049.outbound.protection.outlook.com [104.47.66.49]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3thcx5y47y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MFpM12lXC4jJf2Jt6FZRoJKLJK/z7U883sE8pQ8aVqjjSca0WIhosZN6mjJIb4YNd47van1fKU0zH5oOS6qLtQSEpFg2pbl8dxppo8a54ZXpFuGABu83QenrBOdMpqqlCqe+j0Fv3XMk4/z4+zwVcaLiemvTGtAkQLnRpf7pDf/w0ee824IntH5yq7yWNUVn5mw0/pUeCbeDDeY5/gCTLKkHRCUREQkkEocEwL9bBN+eYYrmjhMWG1MOvlM5xtonPl4/rAU7ccS04MDtQeeUZFSyIOd2BZqpn3iHOCx/63J/5xJdPSV3ll44w81vBzGEIXq02mvXZHwUn70dn9XKcw== 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=o0MJR3MGYLY/0dELN1iGZSmHDYSeiZaeJq1jeiZ/M+M=; b=ZkYLB0EMslE50x+jvDQ+V7YBgHXTunfD89jvwCvnxeaZRar1JrDUl/ut2CsXQk5FOiII/fSVwRDnwAoc/BkbsmkiyPvMUIimfNxg9YmaoQp4rbPmJ+OVkTW6uFCa9M14xTQaHXnfW9NCrsGnJ2lAbsvwQ3IzzyFC1DfM1/5jR61RlWaxL/eDOenwWiDj7jspTTm5y1/S/3sxo38icaK60faUJXSdrb3Ur5l6lrPv3Q6u1tyd0gh8CEpX23bdM3D4A/mXW07FQxrLduP7Eb35VacdcWSbeCnP+2CS801V68XyWW4ya1lqf1sr2qtRKN5Ru0PpHZ5rcFYSB9FbtxvhGQ== 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=o0MJR3MGYLY/0dELN1iGZSmHDYSeiZaeJq1jeiZ/M+M=; b=FhB8y5LD/Gqm8Z4CEhRlJfvp92No5YcXZoS3S/purQ1aGphaqARjjJKRYD8/uCddM/I1t4Egmd0KaHUchUk0/nBze+HW0/1IExd/8IilofLUZo7Z+Zn4z2iAS8wsNwvJ7JbGA81VbvIvxhwMCPsKlSKR0x7cmseESMgAiMAsFSI= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by CH3PR10MB7413.namprd10.prod.outlook.com (2603:10b6:610:154::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Wed, 4 Oct 2023 21:00:30 +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; Wed, 4 Oct 2023 21:00:30 +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 v2 07/12] scsi: sd: Fix sshdr use in sd_suspend_common Date: Wed, 4 Oct 2023 16:00:08 -0500 Message-Id: <20231004210013.5601-8-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com> References: <20231004210013.5601-1-michael.christie@oracle.com> X-ClientProxiedBy: DS7PR03CA0254.namprd03.prod.outlook.com (2603:10b6:5:3b3::19) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|CH3PR10MB7413:EE_ X-MS-Office365-Filtering-Correlation-Id: 67dfb977-3f5d-4167-7ff4-08dbc51cf12c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zh3qgUY8ELq0c0Nm3TSe2X/EGnKljW6mk5Hy1sw5wbYuHCfx1RT73b7bgB1zmYCNhlKqmCDREkqtcMro6bzC+TBJouzpUHJUMklXHCNg0cm9C+DiZslNIoq/dVh/sd31GI57oSI/rEzy/qNjll6UdU//P7woo7GPsS6zgnggo6y2TUrv95QodI1dIzQxSLpQcLIRgyakQG2AGJRFbuyPmVJWLoS488BIAv6eFyEcjW/tC8Gddq3F2YkiN/YT3ovXjzuxTNFZbPgSmNrjdnxLO4UsqlHyrDRgTSFHMh8fHzZXrmkIQN72FMm5m1f5anqjerM7dxNl42CN23Zzkv+IVp1aFrqgwv4lquQ0bcL/wS+gJbjXkIPKMe1YTg3YES6f35Rge3yzaN0RPeU9f9lDW3tzl2nB4Rxkk+fUw9TMO4Y5mSjxLS+TQltO5c9grHTfftCpk8cGQ7UMm6x9/mB61Rck2Qd0/zKsfik9admxmdX2HqRjaQeWPvHvaL+odzFna9PwOh3fTC1w/OzWWTuREtPcq/JWtYL5/DTUVPW/dRDAXVNGU5FHHUhiJKrgw6cT 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)(136003)(376002)(396003)(39860400002)(346002)(366004)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(6666004)(83380400001)(6486002)(6506007)(38100700002)(6512007)(2616005)(26005)(107886003)(1076003)(478600001)(86362001)(66476007)(316002)(66556008)(2906002)(66946007)(41300700001)(5660300002)(8936002)(36756003)(8676002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CHzHc4XB7XPKsaW/KBtHEOAR9mtxCbdWanBmnREamKXKZLRZ2j7OLhspCqUCxbree4kMms7iWNOQezodUvYV96wO5IAyLsUlktKcnM4W0Mc1KeDK6GgWg9rwe83O39ycVyorWo2esk6bP895xflFajp3zPUPgtYdE13E1ogYPYSoBf7p3q3oZBodyty3+Y5tcC7rlfa2VEqA8uG2ySpY/SzjFW5JOtpb/w6EW4nxZwFyaJD7jzf7N3NUXUrxC7+ruBvX3zMPIo6CROi4/sA6R8MFxAY5kLj1rhcPDQQlq35pqMgGwUZowo+oFF1G6d1TgJWJmcNEKLEEN1EzLXE5rcwi6CC8C12hrSBC6owYN+UID0EC8bQ449hEfw9Vu40QooyQkshwgG6fvW7S5u5MbqlzhogMNsA15VPbXDIjumr/3evgsl7Ao1DQ2bJ5EJUc6JSBWddOJKmMcqJ1DKYtMQ0xwd0BHdYh+p8uZzicpKuOBuuivPwuq3JsRqe2DIEs5Q8SP9flyg06l98V5SppxmDocEK5isZU6mRxF8tKIalNF2oSEoHMFNWUSby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1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: egEJh3kq7CG757eoWCciLUPy3HF6z2D9NqU30Bs00/r+a1n93BYNhGDWEQ7cF889QZv0a94ZA2/2wBMkKue8w4fgR4jgio3XeTMwA61X6u40EfUuqnb08HFmuTY0z625XunNLTdjrfceskTT0gQkHg9mSMzbaw2TJZhUsuVfRINaWIc+HciET4eo9xIaoVTnU/oTawFOtbqGCu9q7ctfwIL8QnQGP9avhL+4QY8ExBsYPgTe1eIbC3FxFtZ1fT6LbhHbV3MZVwePp0kYHJt3wSxRVQ6ZB0IKqFOItn3fk3MmM4sni/MT2t3fM19VeFTGQytQtWT5myPj2XaYHi1hjtYrh1Ua/X0xls6LTn4wYLatct8Otj3FIzRmEQDtmkybiz1BAw5zL/AoN+cM0zJwFoL0PRXuL6BTFyjQtk6wiRRXWwwQRK36QJRl3LYpk6TeMWiIqnFe8ZviZeQZlls+tnXMaIAW9BVWmVvC1x9/p0KGC6skmx7Z9qlmKyHJqYhoLlSrlxe3GR36/84p8OCNIEDuvbSUG1I0MWIfSak3qvf54wr/r79adQ2GPl7orJW8TVGW/BohlNseMzK5usPk6MEdAryDCxS1tKkctgTwCXpKdasYN6euMVRLNvVu2/TVHP1nrtBqmvxeDw/87OpxRftU8Bl/PlxviMQfNTghpZ4ZBN2Bl50QSCerlm6W5nyNdzllUvy1hVE5lTuRfA8BkwQPTe3DUMOmG4hBdgGC89SEXGpZXy2tWqvu2MiMucQ+ko7Prrortxcxh7WorWFgG1zUnk9VsCUVivndI/rQIOB1EwVv3ROmyle5Q9ApcWwG94Wpq1ARKU1xZnh3D3vsSDrB46pyPnVHYhspsekhLInG7uNVgVVFyIXp4Id4e300 X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67dfb977-3f5d-4167-7ff4-08dbc51cf12c X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 21:00:30.0188 (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: YAVNno142WETk4lryijBYCdGNKaKy4tTGNRgwKkKV//aIkLH6sbMU8V+agqtQDzyY9tyzZDFQ6bY0dcJ/B0Ve1voQdY8/rzJQD/z1k6XCoE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR10MB7413 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-04_11,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310040155 X-Proofpoint-ORIG-GUID: iRn-5pir3wEmNMFGEDtSQLZUBoCNWx7L X-Proofpoint-GUID: iRn-5pir3wEmNMFGEDtSQLZUBoCNWx7L 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 Reviewed-by: Bart Van Assche --- 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 6e306fe8cb5a..6d4787ff6e96 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -1611,24 +1611,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 }; @@ -1653,15 +1650,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)) { @@ -3817,7 +3822,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 && @@ -3836,7 +3841,6 @@ static inline bool sd_do_start_stop(struct scsi_device *sdev, bool runtime) static int sd_suspend_common(struct device *dev, bool runtime) { 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() */ @@ -3845,24 +3849,13 @@ static int sd_suspend_common(struct device *dev, bool runtime) 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 (sd_do_start_stop(sdkp->device, runtime)) { From patchwork Wed Oct 4 21:00:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13409468 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 98E38E936E7 for ; Wed, 4 Oct 2023 21:02:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244032AbjJDVCy (ORCPT ); Wed, 4 Oct 2023 17:02:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244020AbjJDVCx (ORCPT ); Wed, 4 Oct 2023 17:02:53 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 253E2EB for ; Wed, 4 Oct 2023 14:02:44 -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 394FIvav014490; Wed, 4 Oct 2023 21:00:36 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=c91sGn502pTKXih/VtZSIZ4KpqIsp3SytOpaw0SzOWM=; b=IIy75ezOnh/pIl2J6D4f0MZN/NcaUKUSMQjX/7Fd4g9J8Egi3IpjUDK2pqFMVMskVhI7 KdJUwrjGZy5HYVRBoX9ysOAR/+l80e/NjFIbHZP/poca8FyEOzfQ754W8k0+sakpXaE7 ZDCPwswMpy0TpzeJ+5PB78CGl3wi+xAcx/tudrj35p1/TQc3bIGBwZ3WbtSUJfAmpOtU rNiJXWaEevNrUkREl7cP9Pyh8WqhVQAb50WeEySNY6ggsxCxMAR4oYziAcjcnnluD5PO uSceZQ3h3Q8L3lUvgjeNBcGw+btiXbe2IJguJ3Pg4WJAqtKhpjDIzA4nmvMM8ZDjgbHJ 2Q== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tea9283mf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:35 +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 394KUdwq008859; Wed, 4 Oct 2023 21:00:35 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2047.outbound.protection.outlook.com [104.47.66.47]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tea48p3x1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gzQlDBum6qNkh8AF5Bky5lIbsk1TN6leYdODHP78GUjulZhTGY8uOxecCgW4zb/cPYf5mVMSokkHO7BkVknq9b/9cDRTXyOXfMJ103G3YcRgHtFI4rdMWYIjr8lQYh+4bT/09NGGcxFlW4+A/8OUTeEQXZtrtcX8GVkFQqyL0MJcb06AMJ+25stTEVRTQ+Havk29ctRLjE8s1ZKqT/6vpkyj6aj0zd+dPbDnPlzjFtvtyoHx0a5kZKJMHDP5B1+V1/ugdlYeHZukN2cUVTO1WWxJMid7j/LLIzBxct6BvjUbDzP3V+kfwCK1PmxH2zwW4G+gMjNyLjtp3HGLD9iw0Q== 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=c91sGn502pTKXih/VtZSIZ4KpqIsp3SytOpaw0SzOWM=; b=TxtELtPoqRC+aEbNSwU8OUaH95BlTbP1DGgSEttsadbnNQYgg8+jrkg5WxfEPxuWj2qshGK6SIGn3YKvRfSgb5gWazs6BXBACvIu4q4/gaaUAJeBKlrbyEC+y1a6g+RohknuwBOUiuj5E/gGLZGbNrENsNv0Vk2ZISSyjBuRpcKKZ7S3m3yXTEDHFXNYkyXifxQBI4JK/jOQHcUrZHj/eAzQxZWXiqPEJxq3sfJgkQWVSIKbjXdFXrvHX7omyYS6/5KrEKVY1xIBcXyoJylwIfI0d+Qsep9UVfFGkPWhpOYUgh4mPvF18ixy2+pHvjSGiknxp7wdJpqur5/dpaslnA== 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=c91sGn502pTKXih/VtZSIZ4KpqIsp3SytOpaw0SzOWM=; b=iXR3m9LurLr2qM76ldEcH+0W+YB1HxcAqx3QayV/nVRAtymSnEPMVSS1z/W72sfJzXe1n9UuBjzFHKo8nj2KrHb37GmqgDF7eZjnk3RvzI8ibm7xk01+DufM3Zx1Vc01bqzwZVrh8w+xTKd8m7caw1dhXPQ5G2KwcOFwPS7vYe0= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by SJ0PR10MB5567.namprd10.prod.outlook.com (2603:10b6:a03:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.31; Wed, 4 Oct 2023 21:00:32 +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; Wed, 4 Oct 2023 21:00:32 +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 v2 08/12] scsi: sd: Fix scsi_mode_sense caller's sshdr use Date: Wed, 4 Oct 2023 16:00:09 -0500 Message-Id: <20231004210013.5601-9-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com> References: <20231004210013.5601-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR21CA0011.namprd21.prod.outlook.com (2603:10b6:5:174::21) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|SJ0PR10MB5567:EE_ X-MS-Office365-Filtering-Correlation-Id: 73463e78-c0cb-41fe-f06e-08dbc51cf296 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EK4ouzTFBwhAw0XfU55Iz7ranKl0GCoC3g/cC8AuWGuK9LqetSLX7qQ2HZgD1FOGhLBC+9IZhMqnqW31Hh1DgyNSqQxWFtiEAJ/SLQ6IhKxGw2xhGaYWFv/eWO5z7tkIOHkjFWkK8KuWu9OMWPJNXYn560XaVCA5c9sx+f5is3XhhXCuXiOKHfWEnnA3iTS66TJkhh92FgMXITXOj5LQXW+wIwNlFbnD+F2IDxPDDbzCDAmlobVXgzFP0l0h9KDf87iS/qGxo6vAymwDyuIN+0cenMXM5U/a0MQec7lgEp0RP0PeOV3Hy2XftnHtqwbV77Qc+bQdomHxyETl7VcnHnB0HyKYrGnpFLVJkw5RQTUy/dflKKgc6c956EOgSGaou3Ierm0anxZSF1S6M6rEXr/CRZ8EhavUQYvQ4TNT7wUVgXCf3CnwdKlL1yHbNkuNUGoXeLE8FgszlIqCn1ImZqij6GxnGp68GRaYtc7IZd6FhRccB9IZ6OsGEM0CtJftTId53aPp8OZBGmPorzUQh3BOmamzw2sUSA+QFHZ5ZQMhrQGYbKILYcpxOQZ/wK3g 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)(39860400002)(366004)(396003)(346002)(376002)(136003)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(6666004)(38100700002)(6506007)(6512007)(2616005)(86362001)(36756003)(1076003)(26005)(2906002)(83380400001)(5660300002)(478600001)(6486002)(41300700001)(66556008)(4326008)(316002)(8936002)(107886003)(8676002)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LrQdRRMfSyMyJrevW2L4AYvnVLOGbCw6GP1V45A+FRx9j+4zNpScfBzlBxXyHcAnL8/R3XtQCFdAVdibIi9seYmEujA98v/XYqTKgdiI52ZtGcJ93lUvbGH3RgENNVzIW+8x4sc1zEegmuo5Q05bBs1lWLNVe3B4ZuzoEdX1CjsGE89R33oUBnwyEI2PNTdI4xahiggUwWE6hb2rIJr6swtHZCBC6XpZBajds0TA9nk/GpbBpRv4/x2gt/yuKP5BB+dZrynWJ0x0oBoI50ebLGtvoSxsRDF3ZPX2wVgEmrjxP6S+Uv0hwGgzVYwDbguV4mBliZmLXk5HrNeZIBs55q3FME4/NYvUcTthIxTk1kj5ydn27hXjDW5eM35aUdk0D8KAxbaFsYsF/OUImtFB3JCm3grV1WkJLGJ/HbtkE5Vna4BYPGle6/U2AmMhngcHuMRfRaMHC9VfSumUlPEv0N3ZoJ8iPVTGaugE6Q9qJEQ+Age//7K+P9usb2DH/O9MYimk76bMQtX1ERmYmNBqIJ7e12DYmk3GLuDM98aF7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kZtaHTdQq8v267A== X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: +oHYl3QPJfum2GQP3HbeEtdP0LYaFtDnmD2aIzVJz9OToUEqU2swRrTmQO4tHfq/RsD1+xpOuOvxKWIkLDWhO3GLk5Mu042EB+iR/6Dph5oBdWZAm0N+pFwymnKvEPsqjH7GimMqpQ6pvaA8gvq0RhBZoGRf/C0r8EJZtIwq2i0/FlxHX16eJgwW5cxYXQ4VGd7AV0bZFcoVtTGZ0NjXiJcW2y3XEQAeU2F/v6A9zOPcFNPd/zHL+AMm1FMwbktlen4PFSS2duH6ycHFrylJSSqlHBiddqteja90duIRhXecLCsnxlC9lf2DXy1qQZjy9CRwK4wSY8lXjkRuHrcQF7tX4sPrj2hak/aoaFEIbfBk+8huzxjRjD5rKjCuC1gvQYuWJQMxvN9f6rUp0C/orZPbgY8nPfxidNTG5IqEAyTib/3MJcXoePQy/LFq1YKKFl8c9FspBY47bNrO4USz1ZJT+aXHhXX8BYA5u6XBJOlc2KDaAb2fcI3qEorGtGLICSOHZrCUNJNSPpFqfl2B/TtZby3VFM7HHRvXbFDf/evBbYEyV/LZzFUrVbDoyuT7LpANZBfiTu/c1rN+moYjj4wBzuXAoXv/W/InZGCN+/LA5EVZYSWVFTm0VtlE3oba9MjTtiOc1Do03PbRZylrcYQ+63u2uPVZRMhK+Lg2HNZRc0IGNnT232Ze+wsSoiStrLsoIBWraabyG+EIeya8119mJ/zaMfmjJq+b+eDQNwJWX1mi+WSMOsT4WuCONk/rmdr79lge23PvYM5I8a0hi0agEd1v+aif4MQSwwblVlyFNsrzsbEBbSftjhBDs6LYOZgVi3p95cQ9S+mD9RbcgmXJTfiuSgkwzFjwAH5zAe9XsyPNO+PVAIDiQXFQi2ZY X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73463e78-c0cb-41fe-f06e-08dbc51cf296 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 21:00:32.3653 (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: z0jak8zo23MHKnTePEyRL9oVdelaereUsHw5m51kvRGlMhYGSE5bmJRRK3UxW6S6lJ2Fqf8zvF58AvI/yr5zHc6tystwTb9pbRlnLeKyYJk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5567 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-04_11,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-2310040155 X-Proofpoint-GUID: K1syDOl8HKvQu2omBFXCUAxUvBAkRMo8 X-Proofpoint-ORIG-GUID: K1syDOl8HKvQu2omBFXCUAxUvBAkRMo8 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 6d4787ff6e96..538ebdf42c69 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -2942,7 +2942,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 */ @@ -2990,7 +2990,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 Wed Oct 4 21:00:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13409469 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 1C098E936E8 for ; Wed, 4 Oct 2023 21:02:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244001AbjJDVC4 (ORCPT ); Wed, 4 Oct 2023 17:02:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243974AbjJDVCx (ORCPT ); Wed, 4 Oct 2023 17:02:53 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F5ABF5 for ; Wed, 4 Oct 2023 14:02:44 -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 394FJ9vS016140; Wed, 4 Oct 2023 21:00:38 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=UNYxxC0K3eMhQiA1JHItTYnkgyNyhT92K+TrCQK6qNc7duzNoAsWbT9lLPxnVAU6hXPL 1Oc6xxTjW+k32AEI3FeZsCX2Z9WEpB9IZlwTdAQ578hin+exc+feCmqvqWtzRXpE7WFB jI9UvVZXoeFt5E7KQQk4BA+6GaGwexqP2hoVgSuF360tKtvgPIGnXkMN2SdsCfmi2pQG 6GdqpZ1vMGY64navWJji8cwHmxF6+zBslx6ft+pW0ILMKxSWOPjneL/5ims1BHYADlPo cKkDLlB4SS7tKSVB1qMnm1M5WVkCXkLP5au58jqC8559P4ZsB14V+Qi3Zr+iWAxYGvtf RA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3teakcg4rr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:38 +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 394JbqWv010357; Wed, 4 Oct 2023 21:00:36 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3thcx5y4cj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aFzRYQPUTe7U9Y17SvFXi/wcWnP3D/io8Ohhq/8aTRhhubOZ2MsBnEq6PYpXxema4nBnIENw9A53PHgjCuXdrY43roO9hOoinHI5s/DVvMyISUoYmim45sxZIAXeJJYX8+EaGQkY5uq26e2wGE8xy9q+qsSMiQu03fqJmYDbCmlacwzDDsFiVaJLFd3u/rBPVHeYiWWjPO52jhM17S5dnnQFSgUP93RtWQN7hzC3Lm/eFpfJRjU9y1AnfxFVcfokYEOxBRDQwn7OWHTp+RbR/GeelPQAcIyeXztfBelEsVRiM/gVkSimptkzsCO07WHUUfl2x1xtPETt7+MvwAq3EA== 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=ZGLY01ptBhjo2NgELdYEL59Hbkg/Nek1gMgEq1JCDANh6xgeRy3dNWQSWjE5dVQovElnxuIbvBFEenVbATBfICo5OOD/x95ffntqj4CqLoc2aQ5C0M9SjA/frpLsW+lCOe4UrE1jtdURgPsK8vakmkf0YUnRtTYOpVDW2HLge+gm0wOcyjl0D9G6or/tZrafdN522p6jh2WwOXnsk2wdGfdHSdlsgB5JsaoV8dO7K0t0l8FcJu6fPbrt0acjRxWIyW8A7TtLxllhNffVRdsgmswVD5j/ZH9lTuRDngp7S4oFRhlkCY1gRifP6ya6nWrHewoxer+3FjDAn+PBJczxvw== 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=cxwMd3gMw23Jyoor7MlQTKSxtt3omYLxynE4/4gOQlVWgVnTkGXS6w0Vxas+Bx7aLpgXce4if7Z4IMuUjCrMLqPKbxV0x8zDsF2BoP7tRogUzcUpD79rZ5Q1hYrAT4DM9DR2QVE2K8VdNcMtAh1DWF6O5XTSJqn5RJiDexR+N4o= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by SJ0PR10MB5567.namprd10.prod.outlook.com (2603:10b6:a03:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.31; Wed, 4 Oct 2023 21:00:34 +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; Wed, 4 Oct 2023 21:00:34 +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 v2 09/12] scsi: Fix sshdr use in scsi_test_unit_ready Date: Wed, 4 Oct 2023 16:00:10 -0500 Message-Id: <20231004210013.5601-10-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com> References: <20231004210013.5601-1-michael.christie@oracle.com> X-ClientProxiedBy: DS0PR17CA0021.namprd17.prod.outlook.com (2603:10b6:8:191::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_|SJ0PR10MB5567:EE_ X-MS-Office365-Filtering-Correlation-Id: d60c06e5-ade2-4a72-9c69-08dbc51cf3dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7YwWTWIoV0MTA5SPy5EEw5oEo1j90Q8od/nfLgNoEvkREqr0Al7Z+V+AqXis+Z04t/sikJlyMFWNvlDicuTF9DGLbMRgj5UAekXjTisGX3RtCcBrnBpjgnpgqSDw/hfz5HsEfTPTFwBxbmhHJ3Yi7yI68kYULb4f9qvW8pt4t1GpOQg1YRFm2Fyyo8LUzkG6+6yinxOABguTXLtw1wTjcrPfmySv3TklHKpkk3wwxbDghyeMw64qDgoE64dkHU2jlPaDcztcHv//ml9qo/jvgLfRzzoPRXJ2C2h/YHPFIeJ3FZG9wqlC4y35VgyfW6N79obxhmQkan9v9Zcrfx4wslSEmE5ZJX6GRdBR0HOsx6ighJBEh2UWvtGdiFNAdpZ/Z/iwcd0/BSHJSDW9OW9srFq9Efi78rhPuuIWIUL2PGQYaGbyYVHoxk2PYu7go4We7i3OgVASibw2IpUMK5S6Gs2TPF90K0aTcb0EmW4DdzMda1RUsoxqR9TnXhHHmsjcqUHwjefj0yQv5ftu3Mk1QD6zF1gUFA/NFa3x71isg4e92Hs31l66cS19v/OOYB+R 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)(39860400002)(366004)(396003)(346002)(376002)(136003)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(6666004)(38100700002)(6506007)(6512007)(2616005)(86362001)(36756003)(1076003)(26005)(2906002)(83380400001)(5660300002)(478600001)(6486002)(41300700001)(66556008)(4326008)(316002)(8936002)(107886003)(8676002)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0kWt68S9b99GeSq6EfNDEKDPFlEqJs3/Lip/HBl1SFa+y4C4WQQyesLfon4GKNT7+XwfzZGXyHzE2FdFdaIktXZewjZHBAUSwzEMZ71FtgGFP0XouCq40bXT7/Jp3h9fpO9rRmMFPBWU2xkTYhFDZU8rnYs+cU60Xqp2ro51fr12eyasakNCUSQle3qBtrgk5Ajpg6wwDzjZQ4FYiSCcqIcGaWvzne8LKdX7OOww4MbiYVNG5NQV/d2Tqzr/ygnv70aZ1B+/quuk/BQHhwr3YAzCVi6cMHuQo8vDqKYotUUuUSbhACC5ucxB6Ei2U2pXpGR3vUfzYuMizeq2/eSSfWs6p9to02gbJf4FuhXLKyWBMtosrTH8i9cS1U5MB2i6eNBLA9eyV55BX9xN4wPm7leSevSw7nUxB3fxAW/Uhu9qdlph2y3+zGqN0rm6AyyJz2atHTcSzXK7eGe2oZtZCKWb/yp/qAOiDmqJTsCnYJSPvJldDwv1511NGROKbSYlmu0rlfmziP87a9pMEqte6tQK8AKAH2XBMGS7ndokakq9BvbN5v8hxYNSXT08WjIeed5+YUPiEih+rGw1iKn2rsJRa4kuNw/8Qd451cg7ITjmT/MCFq6oHGrb3YkXSvIpSu1RkpkYljeX4seTDulmreEe5EVP6DG7uPLm8DzVLzycGESUYK3tUo1YdyXbj6+BjG82pn7k0urssj5sbZ3laa0q8tIkQDz/wC14FH8JZbigzT/3/kZMj1ogmob28kAIgxKiQGw82qnOUw4s2LnQc+QkkK4+MWUaq0K9YHvOkLZkYPYpxPOb402v8DckEC+ulE5wQxuMSab/f0oKlYPgJLOHz5GChwd0sbRu1v7UyLj974dAxitr5/6n2Pk45kBVdslZl5hS+gxwUg7ZgE23mxU9SH0qrCPAWSN5V9tnUR1Yteau+ugUkYQIkcxDNfRM8ORHL3qKILH2Ak4qDMkVLxf3y8umaxpu9kH8s21f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fE6qsnAjKJv7zuXuZcm+feD0CvzYz9U7T5Zmd0uMlj2zax8tbPpt5at1OB6P9GxRJ0rrL4Frxai88Au0aDlx0qGOnemteBZY7FoySXFj+VBz5oiYDU7P09YAT1WW65xmLeNs61DyMrcNPKtDb0EEcN2EdKc8Ge93y3RzWL03AOyF2G3eXD3sKDbX9gMwgSU8imgsLTgF+SGR1FkYA5znYCS5h2kZGHsMo65tiIldxzi2CMwfDfZJbWpz9fxsRvPIT7WKOhu8LOvdNbm1bM4PyM6XKtj2Y4SR4J2xO8UDOwp+TQjyXfyFiGsh/HGodz9NmUytzEX0a48cC/dgzwlVvtH0D9tvJ7BIX0yx+VCqg68eB+fQWskOjtjrw9RuPN7zN59iDCXh1rKcYLlehUtb1mDyx9vbbU3sUPKsQ241NgodH5OMXN9D/VOaPPUcbEmn0Aex+mRnXNeYw+PfrCZXFk8Rp0YC4krqTkZBUf2x8DYZNYEE69xATfsmnQ/VYPgq2qj19bgND X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d60c06e5-ade2-4a72-9c69-08dbc51cf3dd X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 21:00:34.5369 (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: j8t3pBoJAQL9J9ZT76w4KLruPuFR7ZZjuhKsiS+bf5C5QJENnEV+CVHMEoUrkHfVznUOYRan3SOQceQ10iqEYBqOIJFNKKcsaN9ymfXGL1c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5567 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-04_11,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310040155 X-Proofpoint-GUID: g9_ws0_13IzmxAHlE5FOPsLED8-_9cqU X-Proofpoint-ORIG-GUID: g9_ws0_13IzmxAHlE5FOPsLED8-_9cqU 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 Wed Oct 4 21:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13409470 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 05F40E936E6 for ; Wed, 4 Oct 2023 21:02:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244007AbjJDVC5 (ORCPT ); Wed, 4 Oct 2023 17:02:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243984AbjJDVCx (ORCPT ); Wed, 4 Oct 2023 17:02:53 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EE615F4 for ; Wed, 4 Oct 2023 14:02:44 -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 394FJ2BW028063; Wed, 4 Oct 2023 21:00:39 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=4BehMNM25HPiYjzmrTbBvlU+ugNxgLRhuXzqKHj0KOQ=; b=yqoMOTHR0qbWG+Km1aL6kZoRj9+zWnYysmrbSNiAawDtWoEQ9K3KIY27dwCuvQwY4NVA wsrcYj3O7YGYj9uiWemhSTwedimhD4UHaB/VCITGa5uXtnr1TkKyamKS1uvsvyKWrgK3 m8Mda68Jnmw/Qaypj7evmtgouInZlKB/OpQB5atnIkoDB5rZ5GZsUC+V1jdHrSPz1GGg S55KeTDtEKYRv+EUk1ODB8vOLitBGlJdygEOVetBKgfpHBLmLiKTnh17Bk/dnlnsn0DX 8mxRdiiR1DaZ+ACzd9Nundh8IhkvSZSNqqXdjq+FsI0h1hisxAVuvV+zWe68Xqtq+xSz MA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tebjbyydk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:38 +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 394JbqWw010357; Wed, 4 Oct 2023 21:00:37 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2044.outbound.protection.outlook.com [104.47.66.44]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3thcx5y4cj-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mUv0PaOAX+D3MIpoGCPJ72vZLogHBrvzV9slQKb4Hi+ecBYgANcFYUGc2Opuh5Y2+VT72G2xfnRhA6W9MdsHI8cWBfvHIlzFBaiV6cDaqsxLEqxxMp8PSnsCq1nTaPbnz1TgeU539pXYOb8emYBOHlC4K59eRlZfZs2H/0Of1MAKJv9BsoKNSlRqK11pkS5+NvAmmzi5KkffIia/KUwqnv9CgnoIqR7dC/RcSqRu9rm1eoOh2NVo0LQv0KwdKDFIsJEQz6f/7FB9zsR4kGaQNDer8ofsums8NF7UyFgZaGhoEc8/31FLBc8Oa4v4lavPPNVq0zHIj+iUrJG5IgivSg== 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=4BehMNM25HPiYjzmrTbBvlU+ugNxgLRhuXzqKHj0KOQ=; b=C17YWTMXXh8u5j3vcuqsfVxt9pY4mIKeGWulokVYYIpMGn2ABiGlOHMmjvpymar3okscMeES32NxRrSkb8o+T81P91qVjr083P/FQBFMugFtlsIYNHCqALEkdvWCLC2C1AkYBLPR7K2AkZrR5kBHMn/STbxlFvDsYGUJ5qxTJ28q3pcAaJUHfBR2jruaxGOtXIueWDpvhVoPgN5TTXKO5B2jYC+xgMTHhhVW/aD9+uMUbXm2xoxv+92cyqG4lBPwlNIzs9cg7ElNgrJXzIpup59cz4AtG8wHYbCnWKaNefsYTc2X3jvoJoKA1WRgnLrt2cN+f2h8bh6/mxv55dXGpA== 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=4BehMNM25HPiYjzmrTbBvlU+ugNxgLRhuXzqKHj0KOQ=; b=VkSzvPWq2Ewodqubfd3mqs9cEzxpv97XYEgnSkpBHXo2IXsrC+y+Iq80VB6/LLwXwFWd/SqaZ/gQFa1KyvKdlJoGSzHIpRZ/GsSed+14gCofGMvt4ZfE5n9AR7fJ+VQ+/IYc71Gz46iExIFdJw5mrgEtu4qx0HFh3VfvgGZaiXA= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by SJ0PR10MB5567.namprd10.prod.outlook.com (2603:10b6:a03:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.31; Wed, 4 Oct 2023 21:00:36 +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; Wed, 4 Oct 2023 21:00:36 +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 v2 10/12] scsi: Fix sshdr use in scsi_cdl_enable Date: Wed, 4 Oct 2023 16:00:11 -0500 Message-Id: <20231004210013.5601-11-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com> References: <20231004210013.5601-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR01CA0029.prod.exchangelabs.com (2603:10b6:5:296::34) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|SJ0PR10MB5567:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b354dc7-785d-489f-ac3c-08dbc51cf4c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l/iW+Slev+LWkpdCtc8ihYz1/1iJrmOdYgCRkJNCAQjOm6gwF08dafACIaVCuCGMW8HYRbyVmfIAMXE6IKx+xPO64g546UBXOeCE4aapfLl+lS8i+w488Bc4Ue/qhv3A31tY6WSAoB7buyX3+4bu5gBL9f43dW1PRQFDLxUDcq5JkopswTxVpzG6PHh0xbz9c781gLAu6OvVCAzIOxM9Rvj3n0ddLEW/+07MaehBLLA4VsrqeOyhXxm8LmyTezUiUKQB8bvqeQ6kkERJLtc6YBh41aIA8ca3m7AWmD2zewzKjenqSJorc/5meLNabcJMdkP/N7pAqPTUKmWzuEN0DpDl+4EO5ja2GKX/gSdM/Z1V8VJHm37ZTVxw11AhbQRe3HkH3LJUAmXGCRogsk71wfjQm7GAY17XqKdcZ/mZqzRjT3UPQ3Rbu9xfuyslo+T0IXc3Ogl8G81dXdCyTN1UdY22hVaVDQfjtA+qNMP0thGfzs3VfArHH77rqaoCmegque08CVlY6kNnEj4ziv4ad/QpYC+1mPHWThIEubaEmpyNX3V/jmxS+W7MW02EQl4l 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)(39860400002)(366004)(396003)(346002)(376002)(136003)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(6666004)(38100700002)(6506007)(6512007)(2616005)(86362001)(36756003)(1076003)(26005)(2906002)(83380400001)(5660300002)(478600001)(6486002)(41300700001)(66556008)(4326008)(316002)(8936002)(107886003)(8676002)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WK4wjNGdQ8EQojd9jvpSQIPaXO0Bg5gVfnN2mfZDCUiy1udBTZMIIssOs6/ZvW9PTieIAgyqJ5ADjT3jnh1BLChOlajApHz/6w5B4EYEdiBl1OmPvyNpZv2O3PY6HN0mRwlt9CC7EKbwFcGK9xf33yZMRH2o1wI6mPeJ39y2U0RHhqQTnIM4Z9hSIeBjM7j/Zdq2HGDGnekMw/lceXHnTnt7Ahqc23Sq+KJcdpT1pykjh3IQoNeMbZpOS2a7Uv8lfeSmn5hCLOD47AKPOvwD7aKHgcS1fd+J3Xnu5ldAIWx6XJtocIpRMQhCzxCKrKjURXVUFRoGAR2mTJzcJxmrjrlPpxaqk1OLUN+32CxZeoADS1DM1rnwEj23uyrX9yU1V1at91sKDxVigEHzJc1xKqZ3Gb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eYzA0Lj0u41a92sbeRKjXzX+hEJZorrBMrnKrsv X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b354dc7-785d-489f-ac3c-08dbc51cf4c9 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 21:00:36.0518 (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: d+R0rMJnOyMPM89v1V6oFBBRE/jlsuSB5LEJhRqNRpIC3sLdrxFo0ZZUoyQbfFrTKKKC4lZh7EI5MT4gKV3SlpZliDtXm2jzu48M540+LEo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5567 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-04_11,2023-10-02_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 phishscore=0 bulkscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2310040155 X-Proofpoint-GUID: a--9sXnlCmiFOEbI1LcFy_7D_gGxzwTM X-Proofpoint-ORIG-GUID: a--9sXnlCmiFOEbI1LcFy_7D_gGxzwTM 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 89367c4bf0ef..76d369343c7a 100644 --- a/drivers/scsi/scsi.c +++ b/drivers/scsi/scsi.c @@ -703,7 +703,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 Wed Oct 4 21:00:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13409472 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 6B2CAE936E9 for ; Wed, 4 Oct 2023 21:03:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244020AbjJDVDC (ORCPT ); Wed, 4 Oct 2023 17:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243899AbjJDVCz (ORCPT ); Wed, 4 Oct 2023 17:02:55 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F660C4 for ; Wed, 4 Oct 2023 14:02:52 -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 394FJ2FS016059; Wed, 4 Oct 2023 21:00:44 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=EaXyyTczHDVfT+tOv5nXUvY1Jn30Q/vkiUima6NUXUI=; b=flsw+rjApRgXhnCMEsWlDiOpiVRghCafz1qFDo2yF8DK0btdp+Rwp+VTILhZv3lJJDTJ ds4iSEKxGGRMjnie325T0fan4jtBzV/vSBR2uso+iOd5QISARQaSeGdbDjapGWskDMSx AtSOdJwX4g7vnJeb7bTXBAkAzTF/bYPDLhT0EKhWtgTrYneBexlRXrjpMilLhU495l85 R0YTbwx7qOcnJ6JIatK2+/jzhHA8S9sOzbXLdGVYO7+A+T7LBy3tBnYfDHP7auB2YR4M LqPzMS/Yp9D2ufQ+I8zq4G9nlHaBTDMpuxq6TzzGZJBEbd5gkTp3YSTTdgG4G8KI84/n 2Q== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3teakcg4s2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:44 +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 394KQ8Tj033614; Wed, 4 Oct 2023 21:00:43 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tea48as2c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Gx17aM6kdOAlCh4pJ/GcQ42FxaI51cBff+/Wj1wqHmxVcKRbPl3SaDcpcSrefJhkuYv+trEBwJD0sx552VUeW89Yv4tlb58DayBtNbcrSjbBt+3JQZ5+Pgw9FpyN2e+ZwjGVfCYn38qQ9iBFlsKvgf7GJhBd1FXO+p6vZ87fDv5G+y7vizt2A2t0pRK7buAOQ/LOxrqIU9m8ssaFlPsH25HPGf5/IMz3G9VBBugcCTy9yBYxLAAEtcRcXeV4DucJxbfKTsHopk+tMRERS1r/qsnIrG4P+c7KDPoHs4jY+iIv4kWZe3/llHU8KysYxrHKSD3QFeLt638urkp5ZB4z4g== 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=EaXyyTczHDVfT+tOv5nXUvY1Jn30Q/vkiUima6NUXUI=; b=Qrxb9wyxzWf9h7L95d+GP6FRrTSim2I+pjJ9P/YsDjj5JCWa/x2Q8ZIqWSGJ0JMhiXJRPX5Jv8m5VtLVYP6j+55yvn+t6JNtGiXuGyuADGe7Jeu98QJ1CqDgERE80FktCRzjhC4BrVaW471bbS2e7Dy/xW8cmbgVKdX1HqDA5kRiO7ZF31kZ/fOvPL4OUjoOc3MpbRhXILtDtgMb11WqJD/eYZOm97y4jfxYzMfPNBF/A6xXrd/uCMSemoQeHR5gvBGRunlHa5/Dmr3ArP7676tPXqgNm3s+bGmAq9eKxSHkbXAGBYXKgHP1cOsaWI2DldydhYroOv1NmyZWMfZ8/g== 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=EaXyyTczHDVfT+tOv5nXUvY1Jn30Q/vkiUima6NUXUI=; b=GRJMhwgCwSkGtd3o6WauA4QfSJTwo9AqbybVqMDGRRTuJ4axiUbTP3HL3JQQCrjLAgu2hre2C7K1X6Jj702F47JW9sz9rLP+Yu9UeiMYMBLYzrxe90Ib9MV6ExBlpWkBlOiQeuZv/YtL5y0WYiCtS3XC7A72fwY6o/jDSHkLoLk= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by SJ0PR10MB5567.namprd10.prod.outlook.com (2603:10b6:a03:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.31; Wed, 4 Oct 2023 21:00:40 +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; Wed, 4 Oct 2023 21:00:37 +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 v2 11/12] scsi: sd: Fix sshdr use in cache_type_store Date: Wed, 4 Oct 2023 16:00:12 -0500 Message-Id: <20231004210013.5601-12-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com> References: <20231004210013.5601-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR02CA0109.namprd02.prod.outlook.com (2603:10b6:5:1b4::11) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|SJ0PR10MB5567:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e6150b6-92c1-40a4-bc2b-08dbc51cf5b5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nf8CIzoiawUWnXHyq0//zG8XE5oU3oxTJOVu5fZSgDBIYUj6NIIAQOwQO4bB0xnHWJ8fna64ppBefqGA/yQeNHlzqeJPe7NCTm3SURmz/imOJTed0bWU/kOaxbjUv+OHDykv+Mx6QNVOKfgCITjv9Huljy/lDSRHc+oEvV5f7wlC8lhSpk7KEqJNpT3U1G6WixRzddZ44/FhIvs+2zH3BpHhPzABoD15rIGoq3RGVv8SUyX7IV/dla2x+nH+wbK2Mz3WI5fIMEa6V+qnrj+F5Bg/UHALST//bkd46nPVTfE68AA4LQMOaobQSQoDsuk2yBXI6rSDBx8N6L/kWLkVGh+8WhpgPEHJ6EdGYSNkTdukk7hkVqhts0WpaEa5p3LJZbqQVlCpjKYlvh7m2nLoQcNm6pdftCyR6F56J0YaogO46MplzyV8Ak4ykdqxy+AG8W54HoOYEX2GO6z4RRVPPxfRagIX44WOy64l7omY64T8aok0Cegv6VfHrrJy4fyWOc464Mc8pKSUiHuz1UVGSAX5dZiYdA8gsZ/j6FNnII6vnqoD7OD/LuS2PutQIwhN 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)(39860400002)(366004)(396003)(346002)(376002)(136003)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(6666004)(38100700002)(6506007)(6512007)(2616005)(86362001)(36756003)(1076003)(26005)(2906002)(83380400001)(5660300002)(478600001)(6486002)(41300700001)(66556008)(4326008)(316002)(8936002)(107886003)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mSqoZ0q8O4QP/zWNjdZEUG+43JI3xrUYqemruK7RQb8VhFnDEUNym7FEerKtoO25ahAR+eIuEFm7ODfKPHSdy7u/zhX1xgXi0ZEeHWznyjFI6cfzPQmLkEyPj69bvJVlqHTV3w2GR/iZNlzIdL8rsOTMcp0bqlSNOo1yc6idTqB/pVaqS3QWILuqwYUVQoUkoQ2Dsy/pGzfwCQg78r3YHWrA8/H7gMlOMo2TgA/2HLTUtGg+4i32DoWqHx0JIPMgJhSzMqCb9+wNDxZa/x7W8UYhSVDSQcthLilb7f3tsnqufrHPj9UVD0RQtEq2NEaJTgvUGJHc60KAxY4/XByKWZHkwOqdEHqd9fOVGfnHCojKhB6VPEvW9lcxluPgLJpKSDxSvCmaWDSUGmSZnRemdsV3ZCoFmY77CnmTRAwLM8DWr9JxyUDTLAyzg21fmmYfZZ3bLotcGQwlmH0sp/VuUo2FtOkhTonD5DgMwagaVbEYrzEMC/dTKE5utIMXtL0nhDk7+QUuMEKsTz0sjK X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e6150b6-92c1-40a4-bc2b-08dbc51cf5b5 X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 21:00:37.6273 (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: JQcJ4wH8S8lEmgoHQNdP99kdBI5PlUurmtB4IMLIUwNV6JJwBrHx1n30E8rS7s7SvpK8LKzvWoMVZy5hfSoYG2gNeSSSJhKxQKg2mmx/A3g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5567 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-04_11,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-2310040155 X-Proofpoint-GUID: GvriUGm8SdKo5hTKziB_8DzZR5hUw0CA X-Proofpoint-ORIG-GUID: GvriUGm8SdKo5hTKziB_8DzZR5hUw0CA 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 538ebdf42c69..8c10b99c5ec1 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 Wed Oct 4 21:00:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 13409473 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 31E5EE936E7 for ; Wed, 4 Oct 2023 21:02:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243994AbjJDVDA (ORCPT ); Wed, 4 Oct 2023 17:03:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233592AbjJDVCz (ORCPT ); Wed, 4 Oct 2023 17:02:55 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09BA99E for ; Wed, 4 Oct 2023 14:02:52 -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 394FIvYX014453; Wed, 4 Oct 2023 21:00:45 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=LKVqgEdPopTSLAiL/pwmZtLJNmvGSul1o2vNSZTx9E3ihfxH5TKFm5qspStdQHI5xeWZ 5aqRlqZBc4ZFcVRdKXOWJFE5N4UYw5rUSIXxf997bctPP6VPcPcPpx2GKbu7FLYDC4zJ jI/4si2xskkxXu2F3FRPmZZkDQMbIodQaUAVer3NKOOPgsFnKwukps7oXEJgGjSh6pyt fh0VEKyJvFEQNNABYwC1wEq02wyhkcfKgD8040LYNGfBZ+Yz0c21n3PyQvVEHypmruUt LMD76jg2Rj/eUD+IEMLKmYcBJyB//mgVWjJSd2wKPDaRWLU+pNjP4c0I3Uh76EnGgZhp Iw== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3tea9283mv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:44 +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 394KQ8Tk033614; Wed, 4 Oct 2023 21:00:44 GMT Received: from nam12-mw2-obe.outbound.protection.outlook.com (mail-mw2nam12lp2045.outbound.protection.outlook.com [104.47.66.45]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3tea48as2c-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 04 Oct 2023 21:00:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZWNey/pjIYceu3933mzSOfjYjTJBqOkGrCtUSUexS3UpNQNk3rIlNPHGlnpbX6ydODzjmrlSNv+PWNOKoduGgSU5jhWXlMXYI32epnzCSyEDwDwosWjzIH3QGmh/rmxqk1hXD1oJUhV2OzzuTBQ/PVd5UOuK9KKt+zJDwoT3qNHu3t8ty0H9o9v9PVCnNSaj+1u/pFM8fLOEHMocJsZw1bYir0gMDEBaejeydz+AkefDqtouCVgnhKxaHyytVA55zejvlW1SWm17EcgVJvHMwzhZbBsw6PLoW4jdgQqVL7utpucU4d/kIStyKDpyzRaqB56g1bPvh7CdANyZpxr4Ag== 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=OZ8NlFeYzmdG/juHieKZYOpl2emo+CBAyMf+FAGDHuEp9/525hLWe3oBDTLrHXEYgEVTlL9Mi5dwpmKm4O99DKOOiLLwWdBFzz0xlQ4MGqscsrODbQmhOhC1QbIcCL9WCzv6+G1Ilu/hsUnwEyqZbqVv1pGN4p/+dEw6qviCzQcs9fiVA9LwbX5rg6XW/tfvNZoFrI4tOgWoAd2qk2UmTbvYfhpJlxevduHEayI8v+iCxYaRGvKcbWvcemY+48fI59a9q9D6cg8nmDWLDI7O3Ju4SlBqzkBnySkR87N6Ug9cMRRPZp9FFVavDk0wgTG3wG7eqI5DvdhrBvqZr53XKA== 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=c8+NCacL99PpGG0MxX1Ajv9tG1n8QZGktq3hj01LC2MRwdKoidD4I+rxh7wUhxTcpSsZKi98YzrZmzjPFdNxWJjrIB5LMHtq3Y9Gv2hqBwXl3ZuCSL9QSWUfA78KqdAiwvvd1BLKVhSl0jn1AGxCpYIZyPwRokgFxM+0JKPzHWo= Received: from CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) by SJ0PR10MB5567.namprd10.prod.outlook.com (2603:10b6:a03:3dd::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.31; Wed, 4 Oct 2023 21:00:41 +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; Wed, 4 Oct 2023 21:00:41 +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 v2 12/12] scsi: sr: Fix sshdr use in sr_get_events Date: Wed, 4 Oct 2023 16:00:13 -0500 Message-Id: <20231004210013.5601-13-michael.christie@oracle.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com> References: <20231004210013.5601-1-michael.christie@oracle.com> X-ClientProxiedBy: DM6PR06CA0066.namprd06.prod.outlook.com (2603:10b6:5:54::43) To CY8PR10MB7243.namprd10.prod.outlook.com (2603:10b6:930:7c::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY8PR10MB7243:EE_|SJ0PR10MB5567:EE_ X-MS-Office365-Filtering-Correlation-Id: 9535acd8-3d10-4fdb-69a2-08dbc51cf69f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XLUbgPH2+RniWbj02t6oR7ImnODZxb1Iq50zWmD0bR5qebwWTXhQefYOWsBzEBrz7fJMTDLGHIZg4jNxa6aNlwlFvwVQrSZS51QT4EhiMPfShmN+DYWPVai4QCr7oci+7sx1R71zcNgKq57zz1P9ZcqdG403FuOPKFQkwVddpeoK8LUw4nCbF7ovxAkC3HoJwj9woRZY3JUVOraiKO3C6jyF71K3klaR7v0EA4zShdgyY54H7GKw+sTM+h8v3QExCZBG6tPgetBr9ky3+WLa8RpIV7myP6x8a6lByCpDfOYPN+yYxLNs+kETPHZ3xsS/IsPjVsEeJs1RuAmf32slR5eR6ZnRBfgwLar90E2CWTrewtPxFNXN9ONLWAO8ZCTodFBnWQhjjwzYzNyPCyl92XafMLFBrivWoKJBJnLSvA8pIJ6rcTI9YLegfdSiemzy5aMyy5P9VyGp0fEkUs32+YGgOA//jP/lOJdYctOxtJ4IzlfhNr24Su6Am01lbudfTsVk6U/eTQP5s07kx3Oc9+LMprR11adj+2mKmZeW2oV6r/9WWOtWQxUi2aV/cuhr 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)(39860400002)(366004)(396003)(346002)(376002)(136003)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(6666004)(38100700002)(6506007)(6512007)(2616005)(86362001)(36756003)(1076003)(26005)(2906002)(83380400001)(5660300002)(478600001)(6486002)(41300700001)(66556008)(4326008)(316002)(8936002)(107886003)(8676002)(66476007)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hAu4q0HJa14T41cSnx6eeXGb8JIacsmLxcDzLJ2Y5etKMgNysWZEji+EAiiKKa88z01wE7DSnwkdSSxDiDYN0XGuTJve+O/zVZ6JRoBj8yWVK39FOYhUQSO1yrdknzfdNjvKVPv1bK/x3dvS58TtVu79LADb2Om2+36VLsvtkvekcAkIVyxVcB9QU11v+IMwHf0qo0vLgtIkN09f3liFeoNAOvBk769+OImeDTn1XMqDQF64++AOT0gGe5t/XlcuX402vfqUb9gbII1DutwwqHg1qR5k4KaoUjz8O6zdNktks2G/tz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iHzKYwawnONPk0vvsSCKy0QfSfH8hF8wc8aY3Ddq+me2EHs0w6U4aiKIUXoRqKwFd4n0k7wo6hYKwtVC/Y7EOlPT3S+/N9p2YMh0FOeM X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9535acd8-3d10-4fdb-69a2-08dbc51cf69f X-MS-Exchange-CrossTenant-AuthSource: CY8PR10MB7243.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Oct 2023 21:00:39.1375 (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: wsyWFIkE21cRGMd1LQkIawJCXLlmSoSzTAlW2Rep33f57/EVchDTKFMqIxRu/qv63kMkmryK5OIM07gmHks9ZqsGiiClQM8eIbg14+sfztQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5567 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-04_11,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-2310040155 X-Proofpoint-GUID: cgQrGsNovEhUkUvwLzqj2GdG0ebkuZO- X-Proofpoint-ORIG-GUID: cgQrGsNovEhUkUvwLzqj2GdG0ebkuZO- 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))