Skip to content

Commit

Permalink
ASoC: tegra_alc5632: fix device_node refcounting
Browse files Browse the repository at this point in the history
tegra_alc5632_probe() increments reference count of device nodes
with of_parse_phandle(), but there is no code decrementing them
in the driver.

The patch adds of_node_put() to tegra_alc5632_remove() and
to error handling paths in the probe.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Alexey Khoroshilov authored and Mark Brown committed Jul 30, 2018
1 parent 7464d3f commit 4321723
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions sound/soc/tegra/tegra_alc5632.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ static int tegra_alc5632_probe(struct platform_device *pdev)
dev_err(&pdev->dev,
"Property 'nvidia,i2s-controller' missing or invalid\n");
ret = -EINVAL;
goto err;
goto err_put_codec_of_node;
}

tegra_alc5632_dai.platform_of_node = tegra_alc5632_dai.cpu_of_node;

ret = tegra_asoc_utils_init(&alc5632->util_data, &pdev->dev);
if (ret)
goto err;
goto err_put_cpu_of_node;

ret = snd_soc_register_card(card);
if (ret) {
Expand All @@ -210,6 +210,13 @@ static int tegra_alc5632_probe(struct platform_device *pdev)

err_fini_utils:
tegra_asoc_utils_fini(&alc5632->util_data);
err_put_cpu_of_node:
of_node_put(tegra_alc5632_dai.cpu_of_node);
tegra_alc5632_dai.cpu_of_node = NULL;
tegra_alc5632_dai.platform_of_node = NULL;
err_put_codec_of_node:
of_node_put(tegra_alc5632_dai.codec_of_node);
tegra_alc5632_dai.codec_of_node = NULL;
err:
return ret;
}
Expand All @@ -223,6 +230,12 @@ static int tegra_alc5632_remove(struct platform_device *pdev)

tegra_asoc_utils_fini(&machine->util_data);

of_node_put(tegra_alc5632_dai.cpu_of_node);
tegra_alc5632_dai.cpu_of_node = NULL;
tegra_alc5632_dai.platform_of_node = NULL;
of_node_put(tegra_alc5632_dai.codec_of_node);
tegra_alc5632_dai.codec_of_node = NULL;

return 0;
}

Expand Down

0 comments on commit 4321723

Please sign in to comment.