* [PATCH] iio: core: check 'info' value before registering the device
@ 2018-12-02 18:30 Andi Shyti
2018-12-08 11:07 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Andi Shyti @ 2018-12-02 18:30 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler,
linux-iio, Andi Shyti
When the 'info' structure inside indio_dev is left uninitialized,
a segmentation fault occurs.
Check the 'info' value before using it and if it is equal to
NULL, return with -EINVAL.
Signed-off-by: Andi Shyti <andi@etezian.org>
---
drivers/iio/industrialio-core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index a062cfddc5af..4f5cd9f60870 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1671,6 +1671,9 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
if (ret < 0)
return ret;
+ if (!indio_dev->info)
+ return -EINVAL;
+
/* configure elements for the chrdev */
indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id);
--
2.20.0.rc1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: core: check 'info' value before registering the device
2018-12-02 18:30 [PATCH] iio: core: check 'info' value before registering the device Andi Shyti
@ 2018-12-08 11:07 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2018-12-08 11:07 UTC (permalink / raw)
To: Andi Shyti
Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald-Stadler, linux-iio
On Sun, 2 Dec 2018 20:30:31 +0200
Andi Shyti <andi@etezian.org> wrote:
> When the 'info' structure inside indio_dev is left uninitialized,
> a segmentation fault occurs.
>
> Check the 'info' value before using it and if it is equal to
> NULL, return with -EINVAL.
>
> Signed-off-by: Andi Shyti <andi@etezian.org>
Hmm. It would be an impressive level of bug if that one got through
in a driver but paranoia does no harm I suppose.
Applied to the togreg branch of iio.git and pushed out as testing
for the autobuilders to play with it.
Thanks,
Jonathan
> ---
> drivers/iio/industrialio-core.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index a062cfddc5af..4f5cd9f60870 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1671,6 +1671,9 @@ int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
> if (ret < 0)
> return ret;
>
> + if (!indio_dev->info)
> + return -EINVAL;
> +
> /* configure elements for the chrdev */
> indio_dev->dev.devt = MKDEV(MAJOR(iio_devt), indio_dev->id);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-12-08 11:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-02 18:30 [PATCH] iio: core: check 'info' value before registering the device Andi Shyti
2018-12-08 11:07 ` 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).