aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio/imu
diff options
context:
space:
mode:
authorAtilla Filiz <atilla.filiz@essensium.com>2014-04-11 10:51:23 -0400
committerJonathan Cameron <jic23@kernel.org>2014-04-26 06:14:51 -0400
commitb9b3a41893c3f1be67b5aacfa525969914bea0e9 (patch)
tree09da1c68f682e1f5b4e4803591bd4857f7e79101 /drivers/iio/imu
parentc60e5760b0a62b072ba00ac07643d9b6fb29f2b4 (diff)
iio:imu:mpu6050: Fixed segfault in Invensens MPU driver due to null dereference
The driver segfaults when the kernel boots with device tree as the platform data is then not present and the pointer is deferenced without checking it is not null. This patch introduces such a check avoiding the crash. Signed-off-by: Atilla Filiz <atilla.filiz@essensium.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Cc: Stable@vger.kernel.org
Diffstat (limited to 'drivers/iio/imu')
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_core.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index cb9f96b446a5..d8ad606c7cd0 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -660,6 +660,7 @@ static int inv_mpu_probe(struct i2c_client *client,
660{ 660{
661 struct inv_mpu6050_state *st; 661 struct inv_mpu6050_state *st;
662 struct iio_dev *indio_dev; 662 struct iio_dev *indio_dev;
663 struct inv_mpu6050_platform_data *pdata;
663 int result; 664 int result;
664 665
665 if (!i2c_check_functionality(client->adapter, 666 if (!i2c_check_functionality(client->adapter,
@@ -672,8 +673,10 @@ static int inv_mpu_probe(struct i2c_client *client,
672 673
673 st = iio_priv(indio_dev); 674 st = iio_priv(indio_dev);
674 st->client = client; 675 st->client = client;
675 st->plat_data = *(struct inv_mpu6050_platform_data 676 pdata = (struct inv_mpu6050_platform_data
676 *)dev_get_platdata(&client->dev); 677 *)dev_get_platdata(&client->dev);
678 if (pdata)
679 st->plat_data = *pdata;
677 /* power is turned on inside check chip type*/ 680 /* power is turned on inside check chip type*/
678 result = inv_check_and_setup_chip(st, id); 681 result = inv_check_and_setup_chip(st, id);
679 if (result) 682 if (result)