Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1666480

[PATCH] ASoC: rockchip: Fix an error handling in 'rockchip_i2s_probe'

From Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Newsgroups linux.kernel
Subject [PATCH] ASoC: rockchip: Fix an error handling in 'rockchip_i2s_probe'
Date 2017-06-15 08:00 +0200
Message-ID <tSvZ1-6W2-7@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
 sound/soc/rockchip/rockchip_i2s.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index af5e0da144f7..f3aa3dfe914b 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -643,12 +643,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;
-- 
2.11.0

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH] ASoC: rockchip: Fix an error handling in 'rockchip_i2s_probe' Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-06-15 08:00 +0200
  Applied "ASoC: rockchip: Fix an error handling in 'rockchip_i2s_probe'" to the asoc tree Mark Brown <broonie@kernel.org> - 2017-06-15 19:30 +0200
    Re: Applied "ASoC: rockchip: Fix an error handling in  'rockchip_i2s_probe'" to the asoc tree Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-06-15 19:40 +0200
      Re: Applied "ASoC: rockchip: Fix an error handling in  'rockchip_i2s_probe'" to the asoc tree Mark Brown <broonie@kernel.org> - 2017-06-15 21:20 +0200
    Re: Applied "ASoC: rockchip: Fix an error handling in  'rockchip_i2s_probe'" to the asoc tree Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2017-06-16 07:00 +0200
      Re: Applied "ASoC: rockchip: Fix an error handling in  'rockchip_i2s_probe'" to the asoc tree Mark Brown <broonie@kernel.org> - 2017-06-16 11:20 +0200

csiph-web