diff mbox

ASoC: rockchip: Fix an error handling in 'rockchip_i2s_probe'

Message ID 20170615055311.8049-1-christophe.jaillet@wanadoo.fr (mailing list archive)
State New, archived
Headers show

Commit Message

Christophe JAILLET June 15, 2017, 5:53 a.m. UTC
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(-)

Comments

kernel test robot June 15, 2017, 11:38 a.m. UTC | #1
Hi Christophe,

[auto build test ERROR on rockchip/for-next]
[also build test ERROR on v4.12-rc5 next-20170615]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Christophe-JAILLET/ASoC-rockchip-Fix-an-error-handling-in-rockchip_i2s_probe/20170615-184817
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=xtensa 

All errors (new ones prefixed by >>):

   sound/soc//rockchip/rockchip_i2s.c: In function 'rockchip_i2s_probe':
>> sound/soc//rockchip/rockchip_i2s.c:619:11: error: expected ')' before 'sizeof'
              sizeof(*soc_dai), GFP_KERNEL);
              ^
>> sound/soc//rockchip/rockchip_i2s.c:618:12: error: too few arguments to function 'devm_kmemdup'
     soc_dai = devm_kmemdup(&pdev->dev, &rockchip_i2s_dai
               ^
   In file included from include/linux/gpio/driver.h:4:0,
                    from include/asm-generic/gpio.h:12,
                    from include/linux/gpio.h:51,
                    from include/linux/of_gpio.h:20,
                    from sound/soc//rockchip/rockchip_i2s.c:16:
   include/linux/device.h:684:14: note: declared here
    extern void *devm_kmemdup(struct device *dev, const void *src, size_t len,
                 ^
>> sound/soc//rockchip/rockchip_i2s.c:621:3: error: 'err' undeclared (first use in this function)
      err = -ENOMEM;
      ^
   sound/soc//rockchip/rockchip_i2s.c:621:3: note: each undeclared identifier is reported only once for each function it appears in

vim +/devm_kmemdup +618 sound/soc//rockchip/rockchip_i2s.c

   612		if (!pm_runtime_enabled(&pdev->dev)) {
   613			ret = i2s_runtime_resume(&pdev->dev);
   614			if (ret)
   615				goto err_pm_disable;
   616		}
   617	
 > 618		soc_dai = devm_kmemdup(&pdev->dev, &rockchip_i2s_dai
 > 619				       sizeof(*soc_dai), GFP_KERNEL);
   620		if (!soc_dai) {
 > 621			err = -ENOMEM;
   622			goto err_pm_disable;
   623		}
   624	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox

Patch

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;