ASoC: fsl: Fix error handling in pcm030_fabric_probe
PATCH 1/1 ASoC: fsl: Fix error handling in pcm030_fabric_probe
This will call twice platform_device_put()
if both platform_device_add() and snd_soc_register_card() fails. Fix it by using goto label to avoid duplicating the error code logic.
--- sound/soc/fsl/pcm030-audio-fabric.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
sound/soc/fsl/pcm030-audio-fabric.c +7 -3
@@ -95,19 +95,23 @@ static int pcm030_fabric_probe(struct platform_device *op) ret =platform_device_add (pdata->codec_device);if (ret) {dev_err (&op->dev,"platform_device_add() failed: %d\n" , ret); -platform_device_put (pdata->codec_device); + goto err_add; } ret =snd_soc_register_card (card);if (ret) {dev_err (&op->dev,"snd_soc_register_card() failed: %d\n" , ret); -platform_device_del (pdata->codec_device); -platform_device_put (pdata->codec_device); + goto err_register; }platform_set_drvdata (op, pdata);return ret; +err_register: +platform_device_del (pdata->codec_device); +err_add: +platform_device_put (pdata->codec_device); +return ret; }static int pcm030_fabric_remove (struct platform_device *op)
Signature · 1 line
2.17.1
Mark Brown
maintainerQuoted 3 lines · Miaoqian Lin
This will call twice
platform_device_put()
if bothplatform_device_add()andsnd_soc_register_card()fails. Fix it by using goto label to avoid duplicating the error code logic.
This doesn't apply against current code, please check and resend.
PATCH v2 1/1 ASoC: fsl: Fix error handling in pcm030_fabric_probe
This will call twice platform_device_put()
if both platform_device_add() and snd_soc_register_card() fails. return early on error to avoid duplicating the error code logic.
---
changes in v2:
- use return statement to return early when fails
- rebase on top of commit 559089e0a93d ("vmalloc: replace VM_NO_HUGE_VMAP with VM_ALLOW_HUGE_VMAP")
--- sound/soc/fsl/pcm030-audio-fabric.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
sound/soc/fsl/pcm030-audio-fabric.c +5 -1
@@ -89,13 +89,16 @@ static int pcm030_fabric_probe(struct platform_device *op)dev_err (&op->dev,"request_module returned: %d\n" , ret); pdata->codec_device =platform_device_alloc ("wm9712-codec" ,-1 ); -if (!pdata->codec_device) +if (!pdata->codec_device) {dev_err (&op->dev,"platform_device_alloc() failed\n" ); +return -ENOMEM ; + } ret =platform_device_add (pdata->codec_device);if (ret) {dev_err (&op->dev,"platform_device_add() failed: %d\n" , ret);platform_device_put (pdata->codec_device); +return ret; } ret =snd_soc_register_card (card);
@@ -103,6 +106,7 @@ static int pcm030_fabric_probe(struct platform_device *op)dev_err (&op->dev,"snd_soc_register_card() failed: %d\n" , ret);platform_device_del (pdata->codec_device);platform_device_put (pdata->codec_device); +return ret; }platform_set_drvdata (op, pdata);
Signature · 1 line
2.17.1
Mark Brown
maintainerQuoted 9 lines · Miaoqian Lin
This will call twice
platform_device_put()
if bothplatform_device_add()andsnd_soc_register_card()fails. return early on error to avoid duplicating the error code logic.Signed-off-by Miaoqian Lin <[email protected]>---
changes in v2:
- use return statement to return early when fails
- rebase on top of commit559089e0a93d("vmalloc: replaceVM_NO_HUGE_VMAPwithVM_ALLOW_HUGE_VMAP")
Why rebase on top of that seemingly random commit? Is there some sort of dependency here?
Quoted 5 lines · Mark Brown
Quoted 4 lines · Miaoqian Lin
This will call twice
platform_device_put()
if bothplatform_device_add()andsnd_soc_register_card()fails. return early on error to avoid duplicating the error code logic.
Quoted 7 lines
Quoted 5 lines
Signed-off-by Miaoqian Lin <[email protected]>---
changes in v2:
- use return statement to return early when fails
- rebase on top of commit559089e0a93d("vmalloc: replaceVM_NO_HUGE_VMAPwithVM_ALLOW_HUGE_VMAP")Why rebase on top of that seemingly random commit? Is there some sort of dependency here?
Hi, it the head of master in when I made this patch. It's because you pointed out
that patch v1 doesn't apply against current code. But I am not sure what's the problem.
So I ensure the codebase is up-to-date. If this patch have no conflict, you can ignore it.
Mark Brown
maintainerQuoted 4 lines · Miaoqian Lin
Quoted 1 line · Mark Brown
Quoted 1 line
- rebase on top of commit
559089e0a93d("vmalloc: replaceVM_NO_HUGE_VMAPwithVM_ALLOW_HUGE_VMAP")
Quoted 8 lines
Quoted 2 lines
Why rebase on top of that seemingly random commit? Is there some sort of dependency here?
Hi, it the head of master in when I made this patch. It's because you pointed out
that patch v1 doesn't apply against current code. But I am not sure what's the problem.
So I ensure the codebase is up-to-date. If this patch have no conflict, you can ignore it.
Current code here is my git tree (-next is often a fair approximation) - if people have been making changes since the merge window then often code written against mainline won't apply and things need to be based on people's current work. You're looking for
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Quoted 8 lines · Mark Brown
Quoted 7 lines · Miaoqian Lin
Quoted 3 lines · Mark Brown
Quoted 1 line
- rebase on top of commit
559089e0a93d("vmalloc: replaceVM_NO_HUGE_VMAPwithVM_ALLOW_HUGE_VMAP")Why rebase on top of that seemingly random commit? Is there some sort of dependency here?
Hi, it the head of master in when I made this patch. It's because you pointed out that patch v1 doesn't apply against current code. But I am not sure what's the problem. So I ensure the codebase is up-to-date. If this patch have no conflict, you can ignore it.
Quoted 6 lines
Current code here is my git tree (-next is often a fair approximation) - if people have been making changes since the merge window then often code written against mainline won't apply and things need to be based on people's current work. You're looking for
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
I get it, thanks for your kindly reminder.