Skip to content

Commit

Permalink
iio: imu: mpu6050: fix possible NULL dereferences
Browse files Browse the repository at this point in the history
Fix possible null dereferencing of i2c and spi driver data.

Signed-off-by: Matt Ranostay <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
Matt Ranostay authored and jic23 committed Mar 5, 2016
1 parent 96c0cb2 commit c816d9e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion drivers/iio/imu/inv_mpu6050/inv_mpu_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ static int inv_mpu_probe(struct i2c_client *client,
struct inv_mpu6050_state *st;
int result;
const char *name = id ? id->name : NULL;
const int chip_type = id ? id->driver_data : 0;
struct regmap *regmap;

if (!i2c_check_functionality(client->adapter,
Expand All @@ -131,7 +132,7 @@ static int inv_mpu_probe(struct i2c_client *client,
}

result = inv_mpu_core_probe(regmap, client->irq, name,
NULL, id->driver_data);
NULL, chip_type);
if (result < 0)
return result;

Expand Down
3 changes: 2 additions & 1 deletion drivers/iio/imu/inv_mpu6050/inv_mpu_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ static int inv_mpu_probe(struct spi_device *spi)
struct regmap *regmap;
const struct spi_device_id *id = spi_get_device_id(spi);
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);
if (IS_ERR(regmap)) {
Expand All @@ -55,7 +56,7 @@ static int inv_mpu_probe(struct spi_device *spi)
}

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)
Expand Down

0 comments on commit c816d9e

Please sign in to comment.