mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomas Henzl <thenzl@redhat.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Dongliang Mu <dzm91@hust.edu.cn>,
	Jing Xu <U202112064@hust.edu.cn>,
	Sathya Prakash <sathya.prakash@broadcom.com>,
	Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
	Suganath Prabu Subramani  <suganath-prabu.subramani@broadcom.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	hust-os-kernel-patches@googlegroups.com,
	MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers: mpt3sas: mpt3sas_debugfs: return value check of `mpt3sas_debugfs_root`
Date: Tue, 23 May 2023 19:56:02 +0200	[thread overview]
Message-ID: <461c6576-71df-c16a-3c4f-4691ae84064f@redhat.com> (raw)
In-Reply-To: <3c4b372f-db4b-43b4-b5ab-7f4860cf6f20@kili.mountain>

On 5/23/23 16:57, Dan Carpenter wrote:
> On Tue, May 23, 2023 at 04:48:12PM +0200, Tomas Henzl wrote:
>> On 5/8/23 16:38, Dan Carpenter wrote:
>>> On Mon, May 08, 2023 at 09:40:41PM +0800, Dongliang Mu wrote:
>>>>>>> diff --git a/drivers/scsi/mpt3sas/mpt3sas_debugfs.c b/drivers/scsi/mpt3sas/mpt3sas_debugfs.c
>>>>>>> index a6ab1db81167..c92e08c130b9 100644
>>>>>>> --- a/drivers/scsi/mpt3sas/mpt3sas_debugfs.c
>>>>>>> +++ b/drivers/scsi/mpt3sas/mpt3sas_debugfs.c
>>>>>>> @@ -99,8 +99,6 @@ static const struct file_operations mpt3sas_debugfs_iocdump_fops = {
>>>>>>>   void mpt3sas_init_debugfs(void)
>>>>>>>   {
>>>>>>>   	mpt3sas_debugfs_root = debugfs_create_dir("mpt3sas", NULL);
>>>>>>> -	if (!mpt3sas_debugfs_root)
>>>>>>> -		pr_info("mpt3sas: Cannot create debugfs root\n");
>>>>>> Hi Jing,
>>>>>> most drivers just ignore the return value but here the author wanted to
>>>>>> have the information logged.
>>>>>> Can you instead of removing the message modify the 'if' condition so it
>>>>>> suits the author's intention?
>>>>>
>>>>> This code was always just wrong.
>>>>>
>>>>> The history of this is slightly complicated and boring.  These days it's
>>>>> harmless dead code so I guess it's less bad than before.
>>>>
>>>> Hi Dan and Tomas,
>>>>
>>>> Any conclusion about this patch? The student Jing Xu is not sure about how
>>>> to revise this patch.
>>>
>>> The correct fix is to delete the code.
>>>
>>> Debugfs code has error checking built in and was never supposed to be
>>> checked for errors in normal driver code.
>>>
>>> Originally, debugfs returned a mix of error pointers and NULL.  In the
>>> kernel, when you have a mix of error pointers and NULL, then the NULL
>>> means that the feature has been disabled deliberately.  It's not an
>>> error, we should not print a message.
>>>
>>> So a different, correct-ish way to write write debugfs error handling
>>> was to say:
>>>
>>> 	mpt3sas_debugfs_root = debugfs_create_dir("mpt3sas", NULL);
>>> 	if (IS_ERR(mpt3sas_debugfs_root))
>>> 		return PTR_ERR(mpt3sas_debugfs_root);
>> I'm fine with this as well, I could wish we get a fix for the exact same
>> case of debugfs_create_dir in mpt3sas_setup_debugfs and ideally all the
>> debugfs_create* in  mpt3sas_debugfs.c in a single patch. But this patch
>> is ok even if that wasn't possible.
>> tomash
> 
> No, you didn't read until the end.  That will break the driver badly.
> 
> This *used* to be a correct-ish way that *used* to work but it was never
> the what Greg wanted.  So to discourage people from doing it, Greg made
> it *impossible* to check for if debugfs has failed.  Literally, the only
> correct thing to do now is to delete the debugfs checking.

I put my comment in on a wrong place I meant the original patch without
the check, sorry for the confusion. The only thing I'd like to see is to
have corrected all debugfs_create* and that is also optional.

> 
> regards,
> dan carpenter
> 
> 


  reply	other threads:[~2023-05-23 17:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-23 12:25 Jing Xu
2023-05-02 15:53 ` Tomas Henzl
2023-05-02 17:06   ` Dan Carpenter
2023-05-08 13:40     ` Dongliang Mu
2023-05-08 14:38       ` Dan Carpenter
2023-05-23 14:48         ` Tomas Henzl
2023-05-23 14:57           ` Dan Carpenter
2023-05-23 17:56             ` Tomas Henzl [this message]
2023-05-24  4:16               ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=461c6576-71df-c16a-3c4f-4691ae84064f@redhat.com \
    --to=thenzl@redhat.com \
    --cc=MPT-FusionLinux.pdl@broadcom.com \
    --cc=U202112064@hust.edu.cn \
    --cc=dan.carpenter@linaro.org \
    --cc=dzm91@hust.edu.cn \
    --cc=hust-os-kernel-patches@googlegroups.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sathya.prakash@broadcom.com \
    --cc=sreekanth.reddy@broadcom.com \
    --cc=suganath-prabu.subramani@broadcom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®