[media] soc-camera: don't dereference I2C client after it has been removed
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>
Wed, 23 Mar 2011 08:26:11 +0000 (05:26 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 13 Apr 2011 12:55:06 +0000 (09:55 -0300)
i2c_unregister_device() frees the I2C client, so, dereferencing it
afterwards is a bug, that leads to Oopses.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/video/soc_camera.c

index 921993060d2f47b13b45a7e0fcab81d5e442ae69..3973f9a94753258da45666085da2b35f9d4ae986 100644 (file)
@@ -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)