linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] do exception handling appropriately in imx_es8328_probe()
@ 2020-08-25 12:05 Yu Kuai
  2020-08-25 12:05 ` [PATCH 1/2] ASoC: fsl: imx-es8328: add missing kfree() call " Yu Kuai
  2020-08-25 12:05 ` [PATCH 2/2] ASoC: fsl: imx-es8328: add missing put_device() " Yu Kuai
  0 siblings, 2 replies; 6+ messages in thread
From: Yu Kuai @ 2020-08-25 12:05 UTC (permalink / raw)
  To: timur, nicoleotsuka, Xiubo.Lee, festevam, shengjiu.wang,
	lgirdwood, broonie, perex, tiwai, shawnguo, s.hauer, kernel,
	linux-imx, xobs
  Cc: alsa-devel, linuxppc-dev, linux-arm-kernel, linux-kernel, yukuai,
	yi.zhang

Yu Kuai (2):
  ASoC: fsl: imx-es8328: add missing kfree() call in imx_es8328_probe()
  ASoC: fsl: imx-es8328: add missing put_device() call in
    imx_es8328_probe()

 sound/soc/fsl/imx-es8328.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

-- 
2.25.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] ASoC: fsl: imx-es8328: add missing kfree() call in imx_es8328_probe()
  2020-08-25 12:05 [PATCH 0/2] do exception handling appropriately in imx_es8328_probe() Yu Kuai
@ 2020-08-25 12:05 ` Yu Kuai
  2020-08-25 12:11   ` Mark Brown
  2020-08-25 12:05 ` [PATCH 2/2] ASoC: fsl: imx-es8328: add missing put_device() " Yu Kuai
  1 sibling, 1 reply; 6+ messages in thread
From: Yu Kuai @ 2020-08-25 12:05 UTC (permalink / raw)
  To: timur, nicoleotsuka, Xiubo.Lee, festevam, shengjiu.wang,
	lgirdwood, broonie, perex, tiwai, shawnguo, s.hauer, kernel,
	linux-imx, xobs
  Cc: alsa-devel, linuxppc-dev, linux-arm-kernel, linux-kernel, yukuai,
	yi.zhang

If memory allocation for 'data' or 'comp' succeed, imx_es8328_probe()
doesn't have corresponding kfree() in exception handling. Thus add
kfree() for this function implementation.

Fixes: 7e7292dba215 ("ASoC: fsl: add imx-es8328 machine driver")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 sound/soc/fsl/imx-es8328.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/sound/soc/fsl/imx-es8328.c b/sound/soc/fsl/imx-es8328.c
index 15a27a2cd0ca..8f71ed3a6f75 100644
--- a/sound/soc/fsl/imx-es8328.c
+++ b/sound/soc/fsl/imx-es8328.c
@@ -151,7 +151,7 @@ static int imx_es8328_probe(struct platform_device *pdev)
 	comp = devm_kzalloc(dev, 3 * sizeof(*comp), GFP_KERNEL);
 	if (!comp) {
 		ret = -ENOMEM;
-		goto fail;
+		goto free_data;
 	}
 
 	data->dev = dev;
@@ -182,12 +182,12 @@ static int imx_es8328_probe(struct platform_device *pdev)
 	ret = snd_soc_of_parse_card_name(&data->card, "model");
 	if (ret) {
 		dev_err(dev, "Unable to parse card name\n");
-		goto fail;
+		goto free_comp;
 	}
 	ret = snd_soc_of_parse_audio_routing(&data->card, "audio-routing");
 	if (ret) {
 		dev_err(dev, "Unable to parse routing: %d\n", ret);
-		goto fail;
+		goto free_comp;
 	}
 	data->card.num_links = 1;
 	data->card.owner = THIS_MODULE;
@@ -196,10 +196,14 @@ static int imx_es8328_probe(struct platform_device *pdev)
 	ret = snd_soc_register_card(&data->card);
 	if (ret) {
 		dev_err(dev, "Unable to register: %d\n", ret);
-		goto fail;
+		goto free_comp;
 	}
 
 	platform_set_drvdata(pdev, data);
+free_comp:
+	kfree(comp);
+free_data:
+	kfree(data);
 fail:
 	of_node_put(ssi_np);
 	of_node_put(codec_np);
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ASoC: fsl: imx-es8328: add missing put_device() call in imx_es8328_probe()
  2020-08-25 12:05 [PATCH 0/2] do exception handling appropriately in imx_es8328_probe() Yu Kuai
  2020-08-25 12:05 ` [PATCH 1/2] ASoC: fsl: imx-es8328: add missing kfree() call " Yu Kuai
@ 2020-08-25 12:05 ` Yu Kuai
  2020-08-27  9:17   ` Marco Felsch
  1 sibling, 1 reply; 6+ messages in thread
From: Yu Kuai @ 2020-08-25 12:05 UTC (permalink / raw)
  To: timur, nicoleotsuka, Xiubo.Lee, festevam, shengjiu.wang,
	lgirdwood, broonie, perex, tiwai, shawnguo, s.hauer, kernel,
	linux-imx, xobs
  Cc: alsa-devel, linuxppc-dev, linux-arm-kernel, linux-kernel, yukuai,
	yi.zhang

if of_find_device_by_node() succeed, imx_es8328_probe() doesn't have
a corresponding put_device(). Thus add a jump target to fix the exception
handling for this function implementation.

Fixes: 7e7292dba215 ("ASoC: fsl: add imx-es8328 machine driver")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 sound/soc/fsl/imx-es8328.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/fsl/imx-es8328.c b/sound/soc/fsl/imx-es8328.c
index 8f71ed3a6f75..a3f121939a83 100644
--- a/sound/soc/fsl/imx-es8328.c
+++ b/sound/soc/fsl/imx-es8328.c
@@ -145,7 +145,7 @@ static int imx_es8328_probe(struct platform_device *pdev)
 	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
 	if (!data) {
 		ret = -ENOMEM;
-		goto fail;
+		goto put_device;
 	}
 
 	comp = devm_kzalloc(dev, 3 * sizeof(*comp), GFP_KERNEL);
@@ -204,6 +204,8 @@ static int imx_es8328_probe(struct platform_device *pdev)
 	kfree(comp);
 free_data:
 	kfree(data);
+put_device:
+	put_device(&ssi_pdev->dev);
 fail:
 	of_node_put(ssi_np);
 	of_node_put(codec_np);
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] ASoC: fsl: imx-es8328: add missing kfree() call in imx_es8328_probe()
  2020-08-25 12:05 ` [PATCH 1/2] ASoC: fsl: imx-es8328: add missing kfree() call " Yu Kuai
@ 2020-08-25 12:11   ` Mark Brown
  2020-08-25 12:57     ` yukuai (C)
  0 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2020-08-25 12:11 UTC (permalink / raw)
  To: Yu Kuai
  Cc: timur, nicoleotsuka, Xiubo.Lee, festevam, shengjiu.wang,
	lgirdwood, perex, tiwai, shawnguo, s.hauer, kernel, linux-imx,
	xobs, alsa-devel, linuxppc-dev, linux-arm-kernel, linux-kernel,
	yukuai, yi.zhang

[-- Attachment #1: Type: text/plain, Size: 559 bytes --]

On Tue, Aug 25, 2020 at 08:05:30PM +0800, Yu Kuai wrote:
> If memory allocation for 'data' or 'comp' succeed, imx_es8328_probe()
> doesn't have corresponding kfree() in exception handling. Thus add
> kfree() for this function implementation.

> @@ -151,7 +151,7 @@ static int imx_es8328_probe(struct platform_device *pdev)
>  	comp = devm_kzalloc(dev, 3 * sizeof(*comp), GFP_KERNEL);
>  	if (!comp) {

The allocation is being done using devm_ which means no explicit kfree()
is needed, the allocation will be automatically unwound when the device
is unbound.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] ASoC: fsl: imx-es8328: add missing kfree() call in imx_es8328_probe()
  2020-08-25 12:11   ` Mark Brown
@ 2020-08-25 12:57     ` yukuai (C)
  0 siblings, 0 replies; 6+ messages in thread
From: yukuai (C) @ 2020-08-25 12:57 UTC (permalink / raw)
  To: Mark Brown
  Cc: timur, nicoleotsuka, Xiubo.Lee, festevam, shengjiu.wang,
	lgirdwood, perex, tiwai, shawnguo, s.hauer, kernel, linux-imx,
	xobs, alsa-devel, linuxppc-dev, linux-arm-kernel, linux-kernel,
	yukuai, yi.zhang


On 2020/08/25 20:11, Mark Brown wrote:
> On Tue, Aug 25, 2020 at 08:05:30PM +0800, Yu Kuai wrote:
>> If memory allocation for 'data' or 'comp' succeed, imx_es8328_probe()
>> doesn't have corresponding kfree() in exception handling. Thus add
>> kfree() for this function implementation.
> 
>> @@ -151,7 +151,7 @@ static int imx_es8328_probe(struct platform_device *pdev)
>>   	comp = devm_kzalloc(dev, 3 * sizeof(*comp), GFP_KERNEL);
>>   	if (!comp) {
> 
> The allocation is being done using devm_ which means no explicit kfree()
> is needed, the allocation will be automatically unwound when the device
> is unbound.

Hi,

Thanks for pointing it out, I'll remove this patch.

Best regards,
Yu Kuai


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] ASoC: fsl: imx-es8328: add missing put_device() call in imx_es8328_probe()
  2020-08-25 12:05 ` [PATCH 2/2] ASoC: fsl: imx-es8328: add missing put_device() " Yu Kuai
@ 2020-08-27  9:17   ` Marco Felsch
  0 siblings, 0 replies; 6+ messages in thread
From: Marco Felsch @ 2020-08-27  9:17 UTC (permalink / raw)
  To: Yu Kuai
  Cc: timur, nicoleotsuka, Xiubo.Lee, festevam, shengjiu.wang,
	lgirdwood, broonie, perex, tiwai, shawnguo, s.hauer, kernel,
	linux-imx, xobs, alsa-devel, yi.zhang, linux-kernel, yukuai,
	linuxppc-dev, linux-arm-kernel

On 20-08-25 20:05, Yu Kuai wrote:
> if of_find_device_by_node() succeed, imx_es8328_probe() doesn't have
> a corresponding put_device().

Why do we need the ssi_pdev reference here at all?

Regards,
  Marco

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-08-27  9:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-25 12:05 [PATCH 0/2] do exception handling appropriately in imx_es8328_probe() Yu Kuai
2020-08-25 12:05 ` [PATCH 1/2] ASoC: fsl: imx-es8328: add missing kfree() call " Yu Kuai
2020-08-25 12:11   ` Mark Brown
2020-08-25 12:57     ` yukuai (C)
2020-08-25 12:05 ` [PATCH 2/2] ASoC: fsl: imx-es8328: add missing put_device() " Yu Kuai
2020-08-27  9:17   ` Marco Felsch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).