Re: [PATCH] siox: fix master memory leak on registration failure
From: Uwe Kleine-König
Date: Mon Sep 21 2026 - 09:25:21 EST
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?
Best regards
Uwe
Attachment:
signature.asc
Description: PGP signature