summaryrefslogtreecommitdiff
path: root/sound/soc/rockchip
diff options
context:
space:
mode:
authorChristophe Jaillet <christophe.jaillet@wanadoo.fr>2017-06-15 07:53:11 +0200
committerMark Brown <broonie@kernel.org>2017-06-15 10:41:33 +0100
commitc3a3d3c41b74b05267bab6173f2a8224a1443ba6 (patch)
treec333163208e4e9ab5179f6e26e78bce2e5c87492 /sound/soc/rockchip
parentec2212c4af20d84841ae288a397d8ee9ecec72a0 (diff)
ASoC: rockchip: Fix an error handling in 'rockchip_i2s_probe'
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>
Diffstat (limited to 'sound/soc/rockchip')
-rw-r--r--sound/soc/rockchip/rockchip_i2s.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index 66a26c56c658..ce09dee2202e 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -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;