Re: [PATCH] siox: fix master memory leak on registration failure

From: Thorsten Scherer

Date: Thu Sep 24 2026 - 09:11:16 EST


Hello everyone,

thank you for the patch and the input.

On Mon, Sep 21, 2026 at 03:02:01PM +0200, Uwe Kleine-König wrote:
> On Mon, Sep 21, 2026 at 12:51:00PM +0200, Markus Elfring wrote:
> > …
> > > +++ b/drivers/siox/siox-core.c
> > > @@ -753,14 +753,21 @@ int siox_master_register(struct siox_master *smaster)
> > > smaster->poll_thread = kthread_run(siox_poll_thread, smaster,
> > > "siox-%d", smaster->busno);
> > > if (IS_ERR(smaster->poll_thread)) {
> > > + ret = PTR_ERR(smaster->poll_thread);
> >
> > Would it be nicer to use this variable assignment directly before
> > the goto statement?
>
> No, please don't, IMHO it's fine to have IS_ERR and PTR_ERR together.
>
> But I wonder if it's sensible to create a function to all the usual init
> stuff such that the error handling in siox_master_register() can become
> just:
>
> get_device(&smaster->dev);
>
> ret = siox_master_init(...);
> if (ret)
> put_device();
>
> return ret;
>
> Having said that, I wonder about the smaster->active = 0 assignment.
> It's quite some time ago that I wrote that code, but either it's
> useless (that's where my bet is on), or this assignment is missing in
> the error path of device_add()? Thorsten?

At a first glance I'm with you. Assignment doesn't change anything.
But I don't have a clear view (on the whole context) yet. The patch
seems legit and fixes a real issue. Having said that, it seems that
there is an additional imbalance at siox_poll_thread.

I will have to take a little time to swap siox in and get a clearer picture.

Coming back to you soon.

> Best regards
> Uwe

Best regards
Thorsten