All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iio: chemical: sgp30: Handle IAQ thread creation failure
@ 2026-07-22  7:48 Linmao Li
  2026-07-22 12:52 ` Joshua Crofts
  0 siblings, 1 reply; 3+ messages in thread
From: Linmao Li @ 2026-07-22  7:48 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: David Lechner, Nuno Sá, Andy Shevchenko, Andreas Brauchli,
	linux-iio, linux-kernel, Linmao Li

kthread_run() can fail and return an error pointer, but sgp_probe() stores
it and returns success, so the device is registered without its IAQ thread
and sgp_remove() later passes the error pointer to kthread_stop(). Return
the error from probe instead.

Fixes: ce514124161a ("iio: chemical: sgp30: Support Sensirion SGP30/SGPC3 sensors")
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
---
 drivers/iio/chemical/sgp30.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/chemical/sgp30.c b/drivers/iio/chemical/sgp30.c
index f10bbebc29e4..379c1c4af8d8 100644
--- a/drivers/iio/chemical/sgp30.c
+++ b/drivers/iio/chemical/sgp30.c
@@ -548,6 +548,9 @@ static int sgp_probe(struct i2c_client *client)
 
 	data->iaq_thread = kthread_run(sgp_iaq_threadfn, data,
 				       "%s-iaq", data->client->name);
+	if (IS_ERR(data->iaq_thread))
+		return dev_err_probe(dev, PTR_ERR(data->iaq_thread),
+				     "failed to start IAQ thread\n");
 
 	return 0;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: chemical: sgp30: Handle IAQ thread creation failure
  2026-07-22  7:48 [PATCH] iio: chemical: sgp30: Handle IAQ thread creation failure Linmao Li
@ 2026-07-22 12:52 ` Joshua Crofts
  2026-07-24 23:21   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Joshua Crofts @ 2026-07-22 12:52 UTC (permalink / raw)
  To: Linmao Li
  Cc: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Andreas Brauchli, linux-iio, linux-kernel

On Wed, 22 Jul 2026 15:48:37 +0800
Linmao Li <lilinmao@kylinos.cn> wrote:

> kthread_run() can fail and return an error pointer, but sgp_probe() stores
> it and returns success, so the device is registered without its IAQ thread
> and sgp_remove() later passes the error pointer to kthread_stop(). Return
> the error from probe instead.
> 
> Fixes: ce514124161a ("iio: chemical: sgp30: Support Sensirion SGP30/SGPC3 sensors")
> Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
> ---
>  drivers/iio/chemical/sgp30.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/iio/chemical/sgp30.c b/drivers/iio/chemical/sgp30.c
> index f10bbebc29e4..379c1c4af8d8 100644
> --- a/drivers/iio/chemical/sgp30.c
> +++ b/drivers/iio/chemical/sgp30.c
> @@ -548,6 +548,9 @@ static int sgp_probe(struct i2c_client *client)
>  
>  	data->iaq_thread = kthread_run(sgp_iaq_threadfn, data,
>  				       "%s-iaq", data->client->name);
> +	if (IS_ERR(data->iaq_thread))
> +		return dev_err_probe(dev, PTR_ERR(data->iaq_thread),
> +				     "failed to start IAQ thread\n");
>  
>  	return 0;
>  }

Good catch! This should also be marked for stable, perhaps Jonathan
can do that while applying.

Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>

-- 
Kind regards,
Joshua Crofts

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: chemical: sgp30: Handle IAQ thread creation failure
  2026-07-22 12:52 ` Joshua Crofts
@ 2026-07-24 23:21   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-07-24 23:21 UTC (permalink / raw)
  To: Joshua Crofts
  Cc: Linmao Li, David Lechner, Nuno Sá, Andy Shevchenko,
	Andreas Brauchli, linux-iio, linux-kernel

On Wed, 22 Jul 2026 14:52:18 +0200
Joshua Crofts <joshua.crofts1@gmail.com> wrote:

> On Wed, 22 Jul 2026 15:48:37 +0800
> Linmao Li <lilinmao@kylinos.cn> wrote:
> 
> > kthread_run() can fail and return an error pointer, but sgp_probe() stores
> > it and returns success, so the device is registered without its IAQ thread
> > and sgp_remove() later passes the error pointer to kthread_stop(). Return
> > the error from probe instead.
> > 
> > Fixes: ce514124161a ("iio: chemical: sgp30: Support Sensirion SGP30/SGPC3 sensors")
> > Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
> > ---
> >  drivers/iio/chemical/sgp30.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/drivers/iio/chemical/sgp30.c b/drivers/iio/chemical/sgp30.c
> > index f10bbebc29e4..379c1c4af8d8 100644
> > --- a/drivers/iio/chemical/sgp30.c
> > +++ b/drivers/iio/chemical/sgp30.c
> > @@ -548,6 +548,9 @@ static int sgp_probe(struct i2c_client *client)
> >  
> >  	data->iaq_thread = kthread_run(sgp_iaq_threadfn, data,
> >  				       "%s-iaq", data->client->name);
> > +	if (IS_ERR(data->iaq_thread))
> > +		return dev_err_probe(dev, PTR_ERR(data->iaq_thread),
> > +				     "failed to start IAQ thread\n");
> >  
> >  	return 0;
> >  }  
> 
> Good catch! This should also be marked for stable, perhaps Jonathan
> can do that while applying.
> 
> Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
> 
I'm not going to rush this one in, so applied to the testing branch
of iio.git and marked for stable so it will make it to stable
releases eventually.

Thanks,

Jonathan



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-24 23:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-22  7:48 [PATCH] iio: chemical: sgp30: Handle IAQ thread creation failure Linmao Li
2026-07-22 12:52 ` Joshua Crofts
2026-07-24 23:21   ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.