public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jose Javier Rodriguez Barbarin <dev-josejavier.rodriguez@duagon.com>
To: Johannes Thumshirn <morbidrsa@gmail.com>
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mcb: Fix incorrect sanity check
Date: Fri, 21 Nov 2025 11:33:35 +0100	[thread overview]
Message-ID: <aSA__wDYAwrS6cNx@MNI-190> (raw)
In-Reply-To: <6b6e7d3e-7219-4459-b177-1e4123c531be@gmail.com>

On Thu, Nov 20, 2025 at 12:48:45PM +0100, Johannes Thumshirn wrote:
> On 11/20/25 12:37 PM, Jose Javier Rodriguez Barbarin wrote:
> > __mcb_register_driver() makes some sanity checks over mcb_driver
> > to check if .probe and .remove callbacks are set. However, not all
> > mcb device drivers implement .remove callback.
> > 
> > Remove .remove check to ensure all mcb device drivers can be loaded.
> 
> The only driver I can see that doesn't implement a .remove method is
> gpio-menz127.c.

Yes. In the past gpio-menz127.c also implemented .remove method, however in

3bd13ae04ccc ("gpio: menz127: simplify error path and remove remove()")

The driver changed, using now devm_* functions so .remove was no longer necessary.

> 
> Is this safe?
> 

From the point of view of mcb bus it should be safe becase I protected the call
of .remove on mcb_remove(), preventing possible crashes when the driver is removed
from the bus.

I'm afraid I'm lossing something because I cannot understand why these changes are or
not safe. Could you explain me why you understand that these changes are unsafe?

The other possible approach is to adding an empty .remove method on gpio-menz127 but
I guess this is not the best way of fixing this.

Regards,

Javier R.

> 
> > 
> > Signed-off-by: Jose Javier Rodriguez Barbarin <dev-josejavier.rodriguez@duagon.com>
> > ---
> >   drivers/mcb/mcb-core.c | 9 +++++----
> >   1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
> > index c1367223e71a..3d487d75c483 100644
> > --- a/drivers/mcb/mcb-core.c
> > +++ b/drivers/mcb/mcb-core.c
> > @@ -85,7 +85,8 @@ static void mcb_remove(struct device *dev)
> >   	struct mcb_device *mdev = to_mcb_device(dev);
> >   	struct module *carrier_mod;
> > -	mdrv->remove(mdev);
> > +	if (mdrv->remove)
> > +		mdrv->remove(mdev);
> >   	carrier_mod = mdev->dev.parent->driver->owner;
> >   	module_put(carrier_mod);
> > @@ -176,13 +177,13 @@ static const struct device_type mcb_carrier_device_type = {
> >    * @owner: The @mcb_driver's module
> >    * @mod_name: The name of the @mcb_driver's module
> >    *
> > - * Register a @mcb_driver at the system. Perform some sanity checks, if
> > - * the .probe and .remove methods are provided by the driver.
> > + * Register a @mcb_driver at the system. Perform a sanity check, if
> > + * .probe method is provided by the driver.
> >    */
> >   int __mcb_register_driver(struct mcb_driver *drv, struct module *owner,
> >   			const char *mod_name)
> >   {
> > -	if (!drv->probe || !drv->remove)
> > +	if (!drv->probe)
> >   		return -EINVAL;
> >   	drv->driver.owner = owner;
> 
> 

  reply	other threads:[~2025-11-21 10:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-20 11:37 [PATCH] mcb: Fix incorrect sanity check Jose Javier Rodriguez Barbarin
2025-11-20 11:48 ` Johannes Thumshirn
2025-11-21 10:33   ` Jose Javier Rodriguez Barbarin [this message]
2025-11-21 10:54     ` Johannes Thumshirn
2025-11-21 11:02       ` Jose Javier Rodriguez Barbarin
2026-01-16 10:30       ` Jose Javier Rodriguez Barbarin
2026-01-16 10:33         ` Johannes Thumshirn
2026-01-16 10:37           ` Jose Javier Rodriguez Barbarin

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=aSA__wDYAwrS6cNx@MNI-190 \
    --to=dev-josejavier.rodriguez@duagon.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=morbidrsa@gmail.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