Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2932985rdh; Wed, 27 Sep 2023 18:39:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH7swdSREkAK8FaL1hjw1lqU6dFUBvtWQHFUTEU78ufthOGS/R2GP4Lh2Xkg4Bn2QEIQEg9 X-Received: by 2002:a25:b297:0:b0:d7a:c493:ef35 with SMTP id k23-20020a25b297000000b00d7ac493ef35mr3491985ybj.58.1695865167027; Wed, 27 Sep 2023 18:39:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695865166; cv=none; d=google.com; s=arc-20160816; b=YI54iOKQ7tfR3w5qq6ycrCoRaf5P1mTrLcQId9WNZfQHSiSErLNAMUk2W6RDA+Yfn8 Aww4ArBptlHWFyleUYQ4g3vC6C0SHAaq/4XKYFqPP/uikcw3Lx4ykIvaxZ5HjYgG6Qsz XZRVJVEceYbv55TCcdWBrqURheuTkk8z7Q3Lw0T+W1+fGwGB1MZnybIprsvZr2nEUzk2 PmUOFikFaSfUi+d4HIdTujOKadspMP3MAbZYOh4pBxabEnopK1JlkN2yrl+nXTzBf60b 3T708rFB4JuNoWi15e4QAVhy3X2SSDGUa02FtW2Gb+xbt3aVHIbO4Ae+aIGn8cvqH1Wf ZHyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=fi81aShWy6tCOr93YRLR3TenrwGigytbikQHhfqP6N0=; fh=1P8NgU50PxHZdbwZcm0RhGfpfaEszaZZUlNuX7tjKbk=; b=0T9JOMiw1hcjYjNi6juv19FolWADy93IPPHCfPdhhAKooNg2uclaJI8IJ6EH8VkZpw RSKfCchCbEP51Jik5PPpi8jZ90e7HSxtsuCZAzM47INAI2SkS2qfP0oH0L8qPjXvVDSG WowxZSgEDWIGfmxNzz3Y12eyrkMLE3ZOQBF70i38bMph3xbxh3qMphdqftFk0FH6l6tf ZPez0/hiPUOok3gPutZ+mLowf88we4IkZ/5bXqdRnJRvbwqDbRYPoSQLdFYBr+3V/Etz c9Iif4DE0Q48QWsYpmxJH0StB7O5tk/6dt7TdaGdkbKCoYqnH7xjNMeNSDOUp73OCYR8 0x3w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id q207-20020a632ad8000000b00565f5281804si17377200pgq.195.2023.09.27.18.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 18:39:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 83CFF822CECD; Wed, 27 Sep 2023 18:39:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229920AbjI1BjD (ORCPT + 99 others); Wed, 27 Sep 2023 21:39:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229437AbjI1BjC (ORCPT ); Wed, 27 Sep 2023 21:39:02 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 783BBAC; Wed, 27 Sep 2023 18:38:59 -0700 (PDT) Received: from kwepemm000012.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Rwx0S45CdzrStx; Thu, 28 Sep 2023 09:36:40 +0800 (CST) Received: from [10.174.178.220] (10.174.178.220) by kwepemm000012.china.huawei.com (7.193.23.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Thu, 28 Sep 2023 09:38:56 +0800 Message-ID: <382fe161-95fb-3249-32cf-07058f81a4bc@huawei.com> Date: Thu, 28 Sep 2023 09:38:55 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v5 01/10] scsi: scsi_debug: create scsi_debug directory in the debugfs filesystem Content-Language: en-US To: , "James E . J . Bottomley" , "Martin K . Petersen" , , CC: , References: <20230922092906.2645265-1-haowenchao2@huawei.com> <20230922092906.2645265-2-haowenchao2@huawei.com> <8c7cfe09-d145-4387-91cf-da9d4e2398e1@interlog.com> From: Wenchao Hao In-Reply-To: <8c7cfe09-d145-4387-91cf-da9d4e2398e1@interlog.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.174.178.220] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm000012.china.huawei.com (7.193.23.142) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 27 Sep 2023 18:39:08 -0700 (PDT) On 2023/9/28 9:13, Douglas Gilbert wrote: > On 2023-09-22 05:28, Wenchao Hao wrote: >> Create directory scsi_debug in the root of the debugfs filesystem. >> Prepare to add interface for manage error injection. >> >> Acked-by: Douglas Gilbert >> Signed-off-by: Wenchao Hao >> --- >>   drivers/scsi/scsi_debug.c | 6 ++++++ >>   1 file changed, 6 insertions(+) >> >> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c >> index 9c0af50501f9..35c336271b13 100644 >> --- a/drivers/scsi/scsi_debug.c >> +++ b/drivers/scsi/scsi_debug.c >> @@ -41,6 +41,7 @@ >>   #include >>   #include >>   #include >> +#include >>   #include >> @@ -862,6 +863,8 @@ static const int device_qfull_result = >>   static const int condition_met_result = SAM_STAT_CONDITION_MET; >> +static struct dentry *sdebug_debugfs_root; >> + >>   /* Only do the extra work involved in logical block provisioning if one or >>    * more of the lbpu, lbpws or lbpws10 parameters are given and we are doing >> @@ -7011,6 +7014,8 @@ static int __init scsi_debug_init(void) >>           goto driver_unreg; >>       } >> +    sdebug_debugfs_root = debugfs_create_dir("scsi_debug", NULL); > > debugfs_create_dir() can fail and return NULL. Looking at other drivers, most > seem to assume it will work. Since the scsi_debug driver is often used to test > abnormal situations, perhaps adding something like: >     if (!sdebug_debugfs_root) >         pr_info("%s: failed to create initial debugfs directory\n", __func__); > > might save someone a bit of time if a NULL dereference on sdebug_debugfs_root > follows later. That is what the mpt3sas driver does. > Yes, I would fix it by checking return value of debugfs related call after your review suggestions for other patches. > Doug Gilbert > >> + >>       for (k = 0; k < hosts_to_add; k++) { >>           if (want_store && k == 0) { >>               ret = sdebug_add_host_helper(idx); >> @@ -7057,6 +7062,7 @@ static void __exit scsi_debug_exit(void) >>       sdebug_erase_all_stores(false); >>       xa_destroy(per_store_ap); >> +    debugfs_remove(sdebug_debugfs_root); >>   } >>   device_initcall(scsi_debug_init); > >