X86 platform drivers
 help / color / mirror / Atom feed
From: Yuan Can <yuancan@huawei.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: <dvhart@infradead.org>, <andy@infradead.org>,
	<tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
	<dave.hansen@linux.intel.com>, <x86@kernel.org>, <hpa@zytor.com>,
	<david.e.box@linux.intel.com>, <jarkko.nikula@linux.intel.com>,
	<wsa@kernel.org>, <hdegoede@redhat.com>,
	<rafael.j.wysocki@intel.com>,
	<platform-driver-x86@vger.kernel.org>
Subject: Re: [PATCH] x86/platform/intel/iosf_mbi: Fix error handling in iosf_mbi_init()
Date: Tue, 15 Nov 2022 16:29:51 +0800	[thread overview]
Message-ID: <d2dbd5f6-eec2-4e6b-60c2-d67aff1af73f@huawei.com> (raw)
In-Reply-To: <CAHp75VfOP=TVL95=LzabQGzf4N3uXHi7KvwH4a_4Ez=vjzL9aQ@mail.gmail.com>


在 2022/11/15 16:26, Andy Shevchenko 写道:
> On Tue, Nov 15, 2022 at 9:38 AM Yuan Can <yuancan@huawei.com> wrote:
>> A problem about modprobe iosf_mbi failed is triggered with the following
>> log given:
>>
>>   debugfs: Directory 'iosf_sb' with parent '/' already present!
>>
>> The reason is that iosf_mbi_init() returns pci_register_driver()
>> directly without checking its return value, if pci_register_driver()
>> failed, it returns without removing debugfs, resulting the debugfs of
>> iosf_sb can never be created later.
>>
>>   iosf_mbi_init()
>>     iosf_mbi_dbg_init() # create debugfs
>>     pci_register_driver()
>>       driver_register()
>>         bus_add_driver()
>>           priv = kzalloc(...) # OOM happened
>>     # return without remove debugfs and destroy workqueue
>>
>> Fix by remove debugfs and iosf_mbi_pm_qos when pci_register_driver()
> removing
>
>> returns error.
>>   static int __init iosf_mbi_init(void)
>>   {
>> +       int ret;
>> +
>>          iosf_debugfs_init();
>>
>>          cpu_latency_qos_add_request(&iosf_mbi_pm_qos, PM_QOS_DEFAULT_VALUE);
>>
>> -       return pci_register_driver(&iosf_mbi_pci_driver);
>> +       ret = pci_register_driver(&iosf_mbi_pci_driver);
>> +       if (ret) {
>> +               cpu_latency_qos_remove_request(&iosf_mbi_pm_qos);
>> +               iosf_debugfs_remove();
>> +       }
>> +
>> +       return ret;
>>   }
> Can we rewrite it as
>
>    if (ret)
>      goto err_remove;
>
>    return 0;
>
> err_remove:
>    ...
>    return ret;
>
> ?
Thanks for these suggestions! will be changed in the next version.

-- 
Best regards,
Yuan Can


      reply	other threads:[~2022-11-15  8:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-15  7:36 [PATCH] x86/platform/intel/iosf_mbi: Fix error handling in iosf_mbi_init() Yuan Can
2022-11-15  8:26 ` Andy Shevchenko
2022-11-15  8:29   ` Yuan Can [this message]

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=d2dbd5f6-eec2-4e6b-60c2-d67aff1af73f@huawei.com \
    --to=yuancan@huawei.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=andy@infradead.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=david.e.box@linux.intel.com \
    --cc=dvhart@infradead.org \
    --cc=hdegoede@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=mingo@redhat.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=tglx@linutronix.de \
    --cc=wsa@kernel.org \
    --cc=x86@kernel.org \
    /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