From: Guennadi Liakhovetski Date: Wed, 23 Mar 2011 08:26:11 +0000 (-0300) Subject: [media] soc-camera: don't dereference I2C client after it has been removed X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c8dd707805af100965c93cdca7d61e61165e9c07;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git [media] soc-camera: don't dereference I2C client after it has been removed i2c_unregister_device() frees the I2C client, so, dereferencing it afterwards is a bug, that leads to Oopses. Signed-off-by: Guennadi Liakhovetski Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 921993060d2f..3973f9a94753 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c @@ -996,10 +996,11 @@ static void soc_camera_free_i2c(struct soc_camera_device *icd) { struct i2c_client *client = to_i2c_client(to_soc_camera_control(icd)); + struct i2c_adapter *adap = client->adapter; dev_set_drvdata(&icd->dev, NULL); v4l2_device_unregister_subdev(i2c_get_clientdata(client)); i2c_unregister_device(client); - i2c_put_adapter(client->adapter); + i2c_put_adapter(adap); } #else #define soc_camera_init_i2c(icd, icl) (-ENODEV)