ASoC: rockchip: Fix an error handling in 'rockchip_i2s_probe'
authorChristophe Jaillet <christophe.jaillet@wanadoo.fr>
Thu, 15 Jun 2017 05:53:11 +0000 (07:53 +0200)
committerMark Brown <broonie@kernel.org>
Thu, 15 Jun 2017 09:41:33 +0000 (10:41 +0100)
If this memory allocation fail, we must disable what has been enabled.
Do not return immediately but go thrue the error handling path instead.

Also use 'devm_kmemdup' instead of 'devm_kzalloc+memcpy' to simplify code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/rockchip/rockchip_i2s.c

index 66a26c56c6589e77dae5356bb4a7182a51fccde5..ce09dee2202e192ef6b8c5a37b9fd13909df16a1 100644 (file)
@@ -641,12 +641,13 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
                        goto err_pm_disable;
        }
 
-       soc_dai = devm_kzalloc(&pdev->dev,
+       soc_dai = devm_kmemdup(&pdev->dev, &rockchip_i2s_dai
                               sizeof(*soc_dai), GFP_KERNEL);
-       if (!soc_dai)
-               return -ENOMEM;
+       if (!soc_dai) {
+               err = -ENOMEM;
+               goto err_pm_disable;
+       }
 
-       memcpy(soc_dai, &rockchip_i2s_dai, sizeof(*soc_dai));
        if (!of_property_read_u32(node, "rockchip,playback-channels", &val)) {
                if (val >= 2 && val <= 8)
                        soc_dai->playback.channels_max = val;