From patchwork Tue Mar 7 10:55:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13163166 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 390A9C76188 for ; Tue, 7 Mar 2023 10:57:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230501AbjCGK5Q (ORCPT ); Tue, 7 Mar 2023 05:57:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230372AbjCGK4q (ORCPT ); Tue, 7 Mar 2023 05:56:46 -0500 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46E9953736; Tue, 7 Mar 2023 02:56:45 -0800 (PST) Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32783kIO010517; Tue, 7 Mar 2023 10:56:42 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-2022-7-12; bh=g+hgas+uJmbPd8ldoWoJBR6FqmoeDKkraJThfdi3n+s=; b=08Wfn7u8I7uJbSGUptnqeMsHilvDUVvEdaalVeAHzOA42mY3Mu/MIBstXyC/EcbHs0i8 qDdRqSq4beqQJbIZOpxOFRjCAmGAsex9JZ5vGrVSe9MygRH9MJQLjKi/RFR3EKG619Sc WNhKGuSCcOo5oFdPGSNS9a0v5ze7OzLdHA1WIvRYlcpFpm5/vSpep98gDqSSVUCwmLLW pVbcg813OE/oAlSkjwOwyfEn3KmCciyDTZeVxo26nwapFPqI+t4qgbrhfDqic6S561XM zey2uj3VfTwMNTY3AFnn/e6fjao04k4IAVqBSecuytl1z7Uh4k0TEad1OTl/mgKlmDhi ug== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p4180w5ra-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Mar 2023 10:56:42 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 3279RxW7011193; Tue, 7 Mar 2023 10:56:42 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p4u2hkp1j-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 07 Mar 2023 10:56:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LuN2F0creOO3syO/fSdQFIC/dMYQ9nS7mas6R+dIYY8mYwQATIJ0AKIfcoz3AUF0oU8VCHioK0H5zkHWE4LYM1EY+dK+IWo1kM+Mov18H0PPrm3+RI0BueCPA1KhmeU3gJg3tKl4m+qzgJRmFDyXZ5BngoiFLJq9z3M6XXy+ROnZP0iBq0/F1Jes1s/SucJcV/v1TGtYX/RBDmmr61w1wGMR/A03ueCoKVNNwyXvM3BJK0fXwA6RhJhgqAhBQJQsnAJkuSTE75tgDSf3QTzcmH4UIBAYpYXOxDwp3r4ugmXU/L8rpw/UY8N3o23FMIMCIzvhTAf3SBv1NzsI//UCdg== 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=g+hgas+uJmbPd8ldoWoJBR6FqmoeDKkraJThfdi3n+s=; b=aN2UKoys2Ludxvx3FFFT3oWgWJavqGFrVbSdTaMhbStXXEgURrSCkJQt0ztf0fa9h+k3qGVRc7cF75NooXLoNFlpDQYemsR/CclymVCzQkWChiBtBOqE5gdWYkJ0oE4ENHYjsnwQfLsrNaopJlfEZ+i4qf3qdc5eYVJnh5NrTkpby3oDhpvVGnHVfRUFmj4ya3xuA8sZ1LKr2MvvMTENO3jvp8AhBL5XxVEkBt+AKM4l8Wwa4CwcuGOW8Ay9IJRoIangNLRYb0WCbMPMnZ6YxflbZNO8zms2SnYY4jVm0xYxmHkMgbhylgO/7E8jv6mLr0AVAQuvGgit9dJ1h9vAOA== 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=g+hgas+uJmbPd8ldoWoJBR6FqmoeDKkraJThfdi3n+s=; b=r6v1EmqiAf+bTDUx8Z53lE2TO4IOUzTZNak68nuiZYq3iyQYLkdkvplIMV5ONzmJdj8AxxAyzILFRpRqVF69tIC9FxAKPeHYNcDaXvCdy6YlR7XogMcLIuHnL80H0+g4PHCgEp3qrVJg/ExJ6wK6b4tRpoqNeEehI5qJuZizEOE= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by DM4PR10MB6719.namprd10.prod.outlook.com (2603:10b6:8:111::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.28; Tue, 7 Mar 2023 10:56:41 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::fff7:981:3ae6:92eb]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::fff7:981:3ae6:92eb%4]) with mapi id 15.20.6156.029; Tue, 7 Mar 2023 10:56:41 +0000 From: John Garry To: jejb@linux.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, dgilbert@interlog.com, John Garry Subject: [PATCH 05/11] scsi: scsi_debug: Drop scsi_debug_target_reset() NULL pointer checks Date: Tue, 7 Mar 2023 10:55:49 +0000 Message-Id: <20230307105555.3745277-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230307105555.3745277-1-john.g.garry@oracle.com> References: <20230307105555.3745277-1-john.g.garry@oracle.com> X-ClientProxiedBy: DM6PR08CA0028.namprd08.prod.outlook.com (2603:10b6:5:80::41) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|DM4PR10MB6719:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b577e37-67ff-4ce1-4d37-08db1efaa1d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZQKyOtnjN/dDRKsQ3n8LEtZSHbYhIZUJnuyuKAsuEpHKaidfwMTFyn46DRx+SvYRcFXgEoXVJFg1AvGYZqNaK3Tmq5StyFfyOrwIuhsw4XyQ7Cy94IR0yKpq2D969ouGtChsXqPXDvOyN3k1MmgbvKj+xK5Ocmba98PxmiT8hiWVXiveHI/B7n4NSZxp/3CCTuYbbwfLnhyfwI0kBAf4WuIDSfhOo74WzAHNi+uRQBwhn+oiAZXrsRvMlKJhlQwTOpSPgYi3v7saSi2CydTZdHfacMRMSloigqroPo5yVu7FxiAP483axoNH1fS+0j+gx0KuaecI99fOJaPsU/9DhVP0MSuXvU7OCRaR+GD0wV3gXDtw9OYKMQEcsrZJIhF6HdKmtcwpl/Odqpx2kZSqVHmiOvMMtx//b+qQISTnZkbioYHNBdulKeoMs5MeoB0Fbpi32dURQeHEOfXyecjSG14f+/m0fA0Rrv9+3MKtGXm9VGPcH4LDohWx9uqOKM2JUkSGpv/IItgyzERzwrnVTKNbhhLXSmQmZzK67C6SwDq7T7xiwp5kBZdFsmqHn2s3QlxM59UBGo12RC3+dgQwXOigU0jjwVRMPdalnIj4zYn8aPHJLa/JCxLy+05Ut4LIBs4D1XlllfdLWoaNQj5vUA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(346002)(396003)(136003)(376002)(366004)(39860400002)(451199018)(103116003)(66946007)(4326008)(66476007)(8676002)(41300700001)(83380400001)(2906002)(86362001)(38100700002)(8936002)(36756003)(66556008)(6486002)(478600001)(6636002)(316002)(5660300002)(26005)(186003)(2616005)(6512007)(1076003)(107886003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: k81oeMgPsVAKSnHei0/4kOqmG1hox5xMBjJSHaQD9RfAwt9KKxGq/vBPGqFuLDhj8pfOsnn6ex8RG7Jd7qrJZkLRKUXM/3vhhLQkKYvlMrPuNTgezHl9l5n8rmom37xkznq6pcdnem50hP9Gdw/1218vhxchXQMydav+M2mqEqJKOvpsgQtbUWEmab99KccisfqIQC21q/1yZ/7dOTRd0S3H2ksvhNwAAaGVpMvkDBIobiUU7SfMN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9txXKEwJrB0qGaNJ1ob8OGtneJNcFPAmcoZUzJ4JbIhqO7Y1VAd5PVTLA/lyK91P0slknTPDXIzwZV/RCr9qc7reqVpxodAwGBqYPHgTzGuJKoRL2p2dUfmphzgBXyZXfoZq+oj54aaF91Ro5SNkNTK997TSvBl+mA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b577e37-67ff-4ce1-4d37-08db1efaa1d6 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Mar 2023 10:56:40.9828 (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: FghyD20cK+rCuFNzTEEnI5+YmD7DsKrgrDyZvOa8A+CoGmkGieNIAMskKj8kt0RJgqUTMbUU43bnu7+kMI6D/A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB6719 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-07_05,2023-03-07_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 suspectscore=0 bulkscore=0 phishscore=0 spamscore=0 mlxlogscore=999 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303070098 X-Proofpoint-ORIG-GUID: 6GUYQJ-9NszgxCX4vLgAfNtmX2-klosN X-Proofpoint-GUID: 6GUYQJ-9NszgxCX4vLgAfNtmX2-klosN Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org The checks for SCSI cmnd, SCSI device, and SCSI host are unnecessary, so drop them. Likewise, drop the NULL check for sdbg_host. The only caller is scsi_try_target_reset() -> eh_target_reset_handler(), and there those pointers cannot be NULL. Signed-off-by: John Garry --- drivers/scsi/scsi_debug.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index b67d0c72118c..33c0df6a3275 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -5389,37 +5389,28 @@ static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt) static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt) { + struct scsi_device *sdp = SCpnt->device; struct sdebug_host_info *sdbg_host; struct sdebug_dev_info *devip; - struct scsi_device *sdp; - struct Scsi_Host *hp; int k = 0; ++num_target_resets; - if (!SCpnt) - goto lie; - sdp = SCpnt->device; - if (!sdp) - goto lie; if (SDEBUG_OPT_ALL_NOISE & sdebug_opts) sdev_printk(KERN_INFO, sdp, "%s\n", __func__); - hp = sdp->host; - if (!hp) - goto lie; - sdbg_host = to_sdebug_host_from_shost(hp); - if (sdbg_host) { - list_for_each_entry(devip, - &sdbg_host->dev_info_list, - dev_list) - if (devip->target == sdp->id) { - set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm); - ++k; - } + + sdbg_host = to_sdebug_host_from_shost(sdp->host); + + list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) { + if (devip->target == sdp->id) { + set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm); + ++k; + } } + if (SDEBUG_OPT_RESET_NOISE & sdebug_opts) sdev_printk(KERN_INFO, sdp, "%s: %d device(s) found in target\n", __func__, k); -lie: + return SUCCESS; }