diff options
author | Atilla Filiz <atilla.filiz@essensium.com> | 2014-04-11 16:51:23 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-06-07 10:28:15 -0700 |
commit | edbfad5ceee721db176f03fb56070ff651b7f2e6 (patch) | |
tree | c973431b7865bff2ba67583dfe29fee11b1011d5 /drivers/iio | |
parent | c6229d9e33fe849bf6f7f16a7813550a1936806a (diff) | |
download | kernel-common-edbfad5ceee721db176f03fb56070ff651b7f2e6.tar.gz kernel-common-edbfad5ceee721db176f03fb56070ff651b7f2e6.tar.bz2 kernel-common-edbfad5ceee721db176f03fb56070ff651b7f2e6.zip |
iio:imu:mpu6050: Fixed segfault in Invensens MPU driver due to null dereference
commit b9b3a41893c3f1be67b5aacfa525969914bea0e9 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/imu/inv_mpu6050/inv_mpu_core.c | 7 |
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 df7f1e1157ae..27a91768cc72 100644 --- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c +++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c @@ -661,6 +661,7 @@ static int inv_mpu_probe(struct i2c_client *client, { struct inv_mpu6050_state *st; struct iio_dev *indio_dev; + struct inv_mpu6050_platform_data *pdata; int result; if (!i2c_check_functionality(client->adapter, @@ -673,8 +674,10 @@ static int inv_mpu_probe(struct i2c_client *client, st = iio_priv(indio_dev); st->client = client; - st->plat_data = *(struct inv_mpu6050_platform_data - *)dev_get_platdata(&client->dev); + pdata = (struct inv_mpu6050_platform_data + *)dev_get_platdata(&client->dev); + if (pdata) + st->plat_data = *pdata; /* power is turned on inside check chip type*/ result = inv_check_and_setup_chip(st, id); if (result) |