media: TDA1997x: fix tda1997x_remove()
authorKrzysztof Hałasa <khalasa@piap.pl>
Fri, 30 Jul 2021 06:59:19 +0000 (08:59 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 30 Sep 2021 08:07:39 +0000 (10:07 +0200)
TDA1997x driver tried to hold two values in a single variable:
device's "client data" pointer was first set to "sd" in
v4l2_i2c_subdev_init(), then it was overwritten explicitly
using dev_set_drvdata() with "state". This caused
tda1997x_remove() to fail badly.

Signed-off-by: Krzysztof Hałasa <khalasa@piap.pl>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/i2c/tda1997x.c

index 6070aaf0b32ead822aab952a0172f95a2b5256f3..1e2a263be933586fc6f64fc783c4cf99c3c700aa 100644 (file)
@@ -2450,7 +2450,8 @@ static const struct media_entity_operations tda1997x_media_ops = {
 static int tda1997x_pcm_startup(struct snd_pcm_substream *substream,
                                struct snd_soc_dai *dai)
 {
-       struct tda1997x_state *state = snd_soc_dai_get_drvdata(dai);
+       struct v4l2_subdev *sd = snd_soc_dai_get_drvdata(dai);
+       struct tda1997x_state *state = to_state(sd);
        struct snd_soc_component *component = dai->component;
        struct snd_pcm_runtime *rtd = substream->runtime;
        int rate, err;
@@ -2759,7 +2760,6 @@ static int tda1997x_probe(struct i2c_client *client,
                        dev_err(&client->dev, "register audio codec failed\n");
                        goto err_free_media;
                }
-               dev_set_drvdata(&state->client->dev, state);
                v4l_info(state->client, "registered audio codec\n");
        }