* [PATCH] iio: imu: inv_mpu6050: Prevent dereferencing NULL
@ 2015-01-09 23:13 Srinivas Pandruvada
2015-01-10 22:08 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Srinivas Pandruvada @ 2015-01-09 23:13 UTC (permalink / raw)
To: jic23; +Cc: linux-iio, Srinivas Pandruvada
When id is null, with ACPI enumeration, don't dereference it.
Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
---
drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index f73e60b..d8d5bed 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -780,7 +780,11 @@ static int inv_mpu_probe(struct i2c_client *client,
i2c_set_clientdata(client, indio_dev);
indio_dev->dev.parent = &client->dev;
- indio_dev->name = id->name;
+ /* id will be NULL when enumerated via ACPI */
+ if (id)
+ indio_dev->name = (char *)id->name;
+ else
+ indio_dev->name = (char *)dev_name(&client->dev);
indio_dev->channels = inv_mpu_channels;
indio_dev->num_channels = ARRAY_SIZE(inv_mpu_channels);
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] iio: imu: inv_mpu6050: Prevent dereferencing NULL
2015-01-09 23:13 [PATCH] iio: imu: inv_mpu6050: Prevent dereferencing NULL Srinivas Pandruvada
@ 2015-01-10 22:08 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2015-01-10 22:08 UTC (permalink / raw)
To: Srinivas Pandruvada; +Cc: linux-iio
On 09/01/15 23:13, Srinivas Pandruvada wrote:
> When id is null, with ACPI enumeration, don't dereference it.
>
> Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Applied to the fixes-togreg branch of iio.git
Thanks,
Jonathan
> ---
> drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> index f73e60b..d8d5bed 100644
> --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
> @@ -780,7 +780,11 @@ static int inv_mpu_probe(struct i2c_client *client,
>
> i2c_set_clientdata(client, indio_dev);
> indio_dev->dev.parent = &client->dev;
> - indio_dev->name = id->name;
> + /* id will be NULL when enumerated via ACPI */
> + if (id)
> + indio_dev->name = (char *)id->name;
> + else
> + indio_dev->name = (char *)dev_name(&client->dev);
> indio_dev->channels = inv_mpu_channels;
> indio_dev->num_channels = ARRAY_SIZE(inv_mpu_channels);
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-10 22:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-09 23:13 [PATCH] iio: imu: inv_mpu6050: Prevent dereferencing NULL Srinivas Pandruvada
2015-01-10 22:08 ` 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).