Skip to contentSkip to conversation

TDA1997x: fix tda1997x_remove()

PATCH Superseded Krzysztof Hałasa 2 participants 3 messages Jul 26, 2021 – Jul 29, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 TDA1997x: fix tda1997x_remove()

TDA1997x I2C "client data" pointer was never set in tda1997x_probe(), then the code tried to use invalid pointer in tda1997x_remove().

drivers/media/i2c/tda1997x.c +1 -0
index 71194746c874..043cc8275d00 100644
@@ -2771,6 +2771,7 @@ static int tda1997x_probe(struct i2c_client *client,
 		goto err_free_media;
 	}
 
+	i2c_set_clientdata(client, sd);
 	return 0;
 
 err_free_media:
#1 lore raw
Quoted 11 lines · Krzysztof Hałasa

TDA1997x I2C "client data" pointer was never set in tda1997x_probe(), then the code tried to use invalid pointer in tda1997x_remove().

drivers/media/i2c/tda1997x.c +0 -0
index 71194746c874..043cc8275d00 100644

drivers/media/i2c/tda1997x.c static int tda1997x_probe(struct i2c_client *client, · line 2777

Quoted 7 lines
drivers/media/i2c/tda1997x.c +1 -0
@@ -2771,6 +2771,7 @@ static int tda1997x_probe(struct i2c_client *client,
 		goto err_free_media;
 	}
 
+	i2c_set_clientdata(client, sd);
 	return 0;
 
 err_free_media:

Actually, v4l2_i2c_subdev_init() sets this, and v4l2_i2c_subdev_init() *is* called. Does it really crash in tda1997x_remove() without this patch?

If so, then I suspect something else is going on.

Regards,

Hans

#2 lore raw

Hans,

Quoted 5 lines · Hans Verkuil
Quoted 5 lines

+++ b/drivers/media/i2c/tda1997x.c

drivers/media/i2c/tda1997x.c +0 -0
@@ -2771,6 +2771,7 @@ static int tda1997x_probe(struct i2c_client *client,
 		goto err_free_media;
 	}
 
Quoted 8 lines

drivers/media/i2c/tda1997x.c static int tda1997x_probe(struct i2c_client *client, · line 2777

Quoted 5 lines
drivers/media/i2c/tda1997x.c +1 -0
+	i2c_set_clientdata(client, sd);
 	return 0;
 
 err_free_media:

Actually, v4l2_i2c_subdev_init() sets this, and v4l2_i2c_subdev_init() *is* called. Does it really crash in tda1997x_remove() without this patch?

Yes, the pointer was once invalid (IIRC), and in other cases NULL.

Quoted 1 line

If so, then I suspect something else is going on.

I'll investigate further, then.

Thanks,

Signature · 5 lines
Krzysztof "Chris" Hałasa

Sieć Badawcza Łukasiewicz
Przemysłowy Instytut Automatyki i Pomiarów PIAP
Al. Jerozolimskie 202, 02-486 Warszawa