From patchwork Mon Mar 13 08:45:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13172075 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 BB2A3C6FD19 for ; Mon, 13 Mar 2023 08:46:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229561AbjCMIqV (ORCPT ); Mon, 13 Mar 2023 04:46:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230186AbjCMIpm (ORCPT ); Mon, 13 Mar 2023 04:45:42 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3083629141; Mon, 13 Mar 2023 01:45:41 -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 32D01VWJ018846; Mon, 13 Mar 2023 08:45:37 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=xBVeTvLzBsoJHRKo7CEnffiNcOIz9zRSdm+Wg+Lq5Qs=; b=tk2hqFK+u2hAV40/ttkFN56/API4z07bYNKTZVKSwXqoExaSo3nnm6UUtydqWTVyRbE3 m8WE5z34a4lMVGBA7682ycAYIHC+5heWYKKxB/7LK4ycuXH1QIjnmLJjg02s2GKU0KYP EjtdUay8TOj9ZCb3boa870D0UhYd6Fs6ayqa0yL/OrqrB0d8XuaKJtD5kkCUQZgOCHLt EWeIqSr9U+02KpGr6MtAwCOuqGHgQexavLodSBRYNeRPU6YDl3t8MqP29M+MAiKCCgPo kpLKbvJhskPcHqCXaTwYaDM5sg9E7t+zPWN68AmEFqJW3N4oFmW0mxXQUJ9n5eFVy9Cj xQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3p8hhab7qu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Mar 2023 08:45:36 +0000 Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32D80TRs015268; Mon, 13 Mar 2023 08:45:35 GMT Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2170.outbound.protection.outlook.com [104.47.57.170]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3p8g34umkd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 13 Mar 2023 08:45:35 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bAe3h5Q+Nsyj3uMWnaRGhPNP9iOLJRIeF9qpsy0zXBJfdORwbkr4+8adPrJdTclRf88t/c53M7+tlrjTH2zxFY/u4UltPhpwMmVe5JgZhvW9AUdtuIU58hRc+DozlTsMh0ibtS9lRHgGByQ6vSCYzRGjPs8pYmYopCLmfKbz6kUiX7An0SQkaDlNFOXrhRCLnaHkxUlG89khcLoLuaiCbF63lK7ULxtqBRH1d3DKb4J4jLU/UnvyX/UUewxnfqbX3YhRnlj2uiZ5DnzR4pyQmfjpbC8B9UNG+ETgUBklFaYr9YPIyBEyIAo20aVUHEAKHQ3KMjAQtg9/6Xc7p3gdRg== 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=xBVeTvLzBsoJHRKo7CEnffiNcOIz9zRSdm+Wg+Lq5Qs=; b=DMjfyF5XApOKg9OJWBDjQbNKrUrGFM6VfaxelzpCDl73nMfJ06CSCNV1SFMkaoOJWac+JcAscHjzNzFFkH/TNSkkfNmKMw0/i0qPmJjzS4c8VbohdHInL0jXCwZQmg+gC71ofZFlChD9E1TKTVnPx6vGabArHNJEDTcs412sNlkNnj4Cgz6uSnEmFv6dd1HMGYPD2ZxXC/PlwZl2Ov2DFZT05XxIjuVlBCY7tOgTwtQ6ZFdbX7dJ2s60b+tWPs2NcNSfFHJDCPsz2T8f7nExOAUHwvBxAdK9O54tPTjttFEzKmDXkvPo7BUO2Mjzk3vwHjW2ad2ebDNIuGWgj/J2QA== 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=xBVeTvLzBsoJHRKo7CEnffiNcOIz9zRSdm+Wg+Lq5Qs=; b=AoZJ8TabH/QeJEQtFSiU4dYONXQS6jS2NFbuHqkUywCr4X0q2xfngFm+mQ76u2ZUrwl5CfYUk1lCi8u1JYxWuToyNWiI2NhzDPAuy9EjXc0+ahBHBTqGtIn6bYsZN6tnMmXOOoqDUMxHB3IPdaMRRUGwjA2FZ0PscXf+YrJ0aeo= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by SJ0PR10MB4703.namprd10.prod.outlook.com (2603:10b6:a03:2d3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.24; Mon, 13 Mar 2023 08:45:33 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::7276:bc4c:17a0:7267]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::7276:bc4c:17a0:7267%6]) with mapi id 15.20.6178.024; Mon, 13 Mar 2023 08:45:33 +0000 From: John Garry To: jejb@linux.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, bvanassche@acm.org, linux-kernel@vger.kernel.org, dgilbert@interlog.com, John Garry Subject: [PATCH v2 05/11] scsi: scsi_debug: Drop scsi_debug_target_reset() NULL pointer checks Date: Mon, 13 Mar 2023 08:45:00 +0000 Message-Id: <20230313084505.1487337-6-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20230313084505.1487337-1-john.g.garry@oracle.com> References: <20230313084505.1487337-1-john.g.garry@oracle.com> X-ClientProxiedBy: BL1PR13CA0218.namprd13.prod.outlook.com (2603:10b6:208:2bf::13) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|SJ0PR10MB4703:EE_ X-MS-Office365-Filtering-Correlation-Id: 6efc1876-b7fb-4ca4-2345-08db239f4ecc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SyrWbZqzjXVnoeIB/KR82OaYaPg/WeHGIS11DYztK8AM7s1d8YwajXjUgDCSKxlEzpqHFc8AhWF0kEqvcKvglrkZAp90gGkXT9bBJEK26eMirE4PeblMR24r/zkRpczJ9mHH5mC7Q9KOPj1cZCUoIBmBZjqbJDQUklTMzeEvgxeeUkbWb1w6qWWo5m77zNPr6pP5cd9v+Tacy3Ix/PxvuAdezVOsVdEuT4znj8bitxePsBA/g9IIqBlotlCCumIIGypomoUfm4TBJTv2M8zaUU2q9TfdhGzbDRla6cCrNK8vh8nZYx74KcvT2OffnEaftqhBSWCK+LTHZU4B2GwE8jkQ+YD80SQoCiSpe7Qst4IiZfPl8DP/ZgtUwHtNlv9ikDhc9ihQIqvmjg2iFGEHX3IhFPDVpl7KrIXZkJ7+2XXr7zG13rh67cj6y5K/RmC0fxJlQ7O4+T5S/omuhU6xG1pdcCEM3+dRhttfRXalp8j602CB10OJ9ZSs/uFx85SGnDIGwzsV/i7LAoru85qm7J97/l7OpksBJub8y9rAGyVcNWvcpsOeXmmQ6aDwY3RV2MdOK2QnaUbBejyHezWkHRglHMBA9WXyjJD9wPs7HDhLYxHKVuhtqaHkcxHfWkVcRvwqhtuiiprmemaGGrt3Dg== 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)(396003)(136003)(346002)(376002)(39860400002)(366004)(451199018)(2906002)(83380400001)(36756003)(5660300002)(66946007)(66556008)(41300700001)(8936002)(4326008)(103116003)(8676002)(66476007)(38100700002)(6636002)(86362001)(316002)(478600001)(186003)(2616005)(6486002)(26005)(107886003)(6666004)(6506007)(1076003)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5F5nazqTwaZCzvrjTExfSfGE6FrdR3JnPSHU5KTRul0l4F/L/0QxWVYF9i6zUdM18BLd4e+dsovpyVMixtg4Oe5RqsA4l3pnMO7Vhg4usOS+zwJNhYFQbr65PfdNA21cJvfiwdnVJMTNczc3fjUgElIdf8BbIUaA1DEfKvVEByZDwU5d0BgKjE8wm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UCiEO8R5OrCIiqeIebdTWpZIk9dw1FAFgEf6C7PyBm99L7IxRfjShECoycseMxodWgXrFeX3VMFVpGvaCLuu4E/C22MbZPs7II/q0VKOMJwRHEi2DbPhcCl7jglzY3O1ybVUIy5MYhuY7MECU/zZVSA+OoWdn1XYH34WBzdWTFsdbPzUKHDDYEnLa+AAfa4M1DZvgyy7AKluI= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6efc1876-b7fb-4ca4-2345-08db239f4ecc X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Mar 2023 08:45:33.3392 (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: +bG1ywTH0+7LRYN6nD1/BDkyLOQBv3KVer3mzoTHgcGr05Htkz6yOQdr/sZlFhj2eW1JVB++BiuTZ05lk+sLSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB4703 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-03-12_10,2023-03-10_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 spamscore=0 suspectscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2303130070 X-Proofpoint-GUID: RXYyu_QfbLQIgz2d5rZxMLOUXp8-C--r X-Proofpoint-ORIG-GUID: RXYyu_QfbLQIgz2d5rZxMLOUXp8-C--r 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, 10 insertions(+), 21 deletions(-) diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 5b51c24f7d09..6364d6f08861 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -5387,37 +5387,26 @@ static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt) static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt) { - struct sdebug_host_info *sdbg_host; + struct scsi_device *sdp = SCpnt->device; + struct sdebug_host_info *sdbg_host = shost_to_sdebug_host(sdp->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 = shost_to_sdebug_host(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; - } + + 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; }