* [PATCH] iio: core: Fix an error pointer vs NULL bug in devm_iio_device_alloc()
@ 2021-05-15 9:56 Dan Carpenter
2021-05-16 5:30 ` Alexandru Ardelean
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-05-15 9:56 UTC (permalink / raw)
To: Jonathan Cameron, Yicong Yang
Cc: Lars-Peter Clausen, Nuno Sa, Andy Shevchenko, linux-iio, kernel-janitors
The devm_iio_device_alloc() function is supposed to return NULL and not
error pointers. Returning an error pointer will lead to a crash in the
callers.
Fixes: d240dc25e3b8 ("iio: core: simplify some devm functions")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/iio/industrialio-core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index bfa20a346f71..75e92bac78f3 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1711,7 +1711,7 @@ struct iio_dev *devm_iio_device_alloc(struct device *parent, int sizeof_priv)
ret = devm_add_action_or_reset(parent, devm_iio_device_release,
iio_dev);
if (ret)
- return ERR_PTR(ret);
+ return NULL;
return iio_dev;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: core: Fix an error pointer vs NULL bug in devm_iio_device_alloc()
2021-05-15 9:56 [PATCH] iio: core: Fix an error pointer vs NULL bug in devm_iio_device_alloc() Dan Carpenter
@ 2021-05-16 5:30 ` Alexandru Ardelean
2021-05-16 9:09 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Alexandru Ardelean @ 2021-05-16 5:30 UTC (permalink / raw)
To: Dan Carpenter
Cc: Jonathan Cameron, Yicong Yang, Lars-Peter Clausen, Nuno Sa,
Andy Shevchenko, linux-iio, kernel-janitors
On Sat, May 15, 2021 at 3:01 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> The devm_iio_device_alloc() function is supposed to return NULL and not
> error pointers. Returning an error pointer will lead to a crash in the
> callers.
>
oh
that's a good catch;
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
> Fixes: d240dc25e3b8 ("iio: core: simplify some devm functions")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/iio/industrialio-core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index bfa20a346f71..75e92bac78f3 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1711,7 +1711,7 @@ struct iio_dev *devm_iio_device_alloc(struct device *parent, int sizeof_priv)
> ret = devm_add_action_or_reset(parent, devm_iio_device_release,
> iio_dev);
> if (ret)
> - return ERR_PTR(ret);
> + return NULL;
>
> return iio_dev;
> }
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: core: Fix an error pointer vs NULL bug in devm_iio_device_alloc()
2021-05-16 5:30 ` Alexandru Ardelean
@ 2021-05-16 9:09 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2021-05-16 9:09 UTC (permalink / raw)
To: Alexandru Ardelean
Cc: Dan Carpenter, Yicong Yang, Lars-Peter Clausen, Nuno Sa,
Andy Shevchenko, linux-iio, kernel-janitors
On Sun, 16 May 2021 08:30:20 +0300
Alexandru Ardelean <ardeleanalex@gmail.com> wrote:
> On Sat, May 15, 2021 at 3:01 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
> >
> > The devm_iio_device_alloc() function is supposed to return NULL and not
> > error pointers. Returning an error pointer will lead to a crash in the
> > callers.
> >
>
> oh
> that's a good catch;
>
> Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders
to poke at it.
Thanks,
Jonathan
>
> > Fixes: d240dc25e3b8 ("iio: core: simplify some devm functions")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > drivers/iio/industrialio-core.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> > index bfa20a346f71..75e92bac78f3 100644
> > --- a/drivers/iio/industrialio-core.c
> > +++ b/drivers/iio/industrialio-core.c
> > @@ -1711,7 +1711,7 @@ struct iio_dev *devm_iio_device_alloc(struct device *parent, int sizeof_priv)
> > ret = devm_add_action_or_reset(parent, devm_iio_device_release,
> > iio_dev);
> > if (ret)
> > - return ERR_PTR(ret);
> > + return NULL;
> >
> > return iio_dev;
> > }
> > --
> > 2.30.2
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-16 9:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-15 9:56 [PATCH] iio: core: Fix an error pointer vs NULL bug in devm_iio_device_alloc() Dan Carpenter
2021-05-16 5:30 ` Alexandru Ardelean
2021-05-16 9:09 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).