Commit c816d9e7 authored by Matt Ranostay's avatar Matt Ranostay Committed by Jonathan Cameron

iio: imu: mpu6050: fix possible NULL dereferences

Fix possible null dereferencing of i2c and spi driver data.
Signed-off-by: default avatarMatt Ranostay <matt.ranostay@intel.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 96c0cb2b
...@@ -117,6 +117,7 @@ static int inv_mpu_probe(struct i2c_client *client, ...@@ -117,6 +117,7 @@ static int inv_mpu_probe(struct i2c_client *client,
struct inv_mpu6050_state *st; struct inv_mpu6050_state *st;
int result; int result;
const char *name = id ? id->name : NULL; const char *name = id ? id->name : NULL;
const int chip_type = id ? id->driver_data : 0;
struct regmap *regmap; struct regmap *regmap;
if (!i2c_check_functionality(client->adapter, if (!i2c_check_functionality(client->adapter,
...@@ -131,7 +132,7 @@ static int inv_mpu_probe(struct i2c_client *client, ...@@ -131,7 +132,7 @@ static int inv_mpu_probe(struct i2c_client *client,
} }
result = inv_mpu_core_probe(regmap, client->irq, name, result = inv_mpu_core_probe(regmap, client->irq, name,
NULL, id->driver_data); NULL, chip_type);
if (result < 0) if (result < 0)
return result; return result;
......
...@@ -46,6 +46,7 @@ static int inv_mpu_probe(struct spi_device *spi) ...@@ -46,6 +46,7 @@ static int inv_mpu_probe(struct spi_device *spi)
struct regmap *regmap; struct regmap *regmap;
const struct spi_device_id *id = spi_get_device_id(spi); const struct spi_device_id *id = spi_get_device_id(spi);
const char *name = id ? id->name : NULL; const char *name = id ? id->name : NULL;
const int chip_type = id ? id->driver_data : 0;
regmap = devm_regmap_init_spi(spi, &inv_mpu_regmap_config); regmap = devm_regmap_init_spi(spi, &inv_mpu_regmap_config);
if (IS_ERR(regmap)) { if (IS_ERR(regmap)) {
...@@ -55,7 +56,7 @@ static int inv_mpu_probe(struct spi_device *spi) ...@@ -55,7 +56,7 @@ static int inv_mpu_probe(struct spi_device *spi)
} }
return inv_mpu_core_probe(regmap, spi->irq, name, return inv_mpu_core_probe(regmap, spi->irq, name,
inv_mpu_i2c_disable, id->driver_data); inv_mpu_i2c_disable, chip_type);
} }
static int inv_mpu_remove(struct spi_device *spi) static int inv_mpu_remove(struct spi_device *spi)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment