lkml.org 
[lkml]   [2019]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [alsa-devel] [PATCH v3 2/6] ASoC: amd: Refactoring of DAI from DMA driver
From
Date

> +static int acp3x_dai_probe(struct platform_device *pdev)
> +{
> + int status;
> + struct resource *res;
> + struct i2s_dev_data *adata;
> +
> + if (!pdev->dev.platform_data) {
> + dev_err(&pdev->dev, "platform_data not retrieved\n");
> + return -ENODEV;
> + }
> +
> + adata = devm_kzalloc(&pdev->dev, sizeof(struct i2s_dev_data),
> + GFP_KERNEL);

if (!adata)
return -ENOMEM;
> + res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> + if (!res) {
> + dev_err(&pdev->dev, "IORESOURCE_MEM FAILED\n");
> + return -ENODEV;
> + }
> +
> + adata->acp3x_base = devm_ioremap(&pdev->dev, res->start,
> + resource_size(res));
> + if (IS_ERR(adata->acp3x_base))
> + return PTR_ERR(adata->acp3x_base);
> +
> + adata->i2s_irq = res->start;
> + dev_set_drvdata(&pdev->dev, adata);
> + status = devm_snd_soc_register_component(&pdev->dev,
> + &acp3x_dai_component,
> + &acp3x_i2s_dai, 1);
> + if (status) {
> + dev_err(&pdev->dev, "Fail to register acp i2s dai\n");
> + return -ENODEV;

if the probe fails for such errors, don't you have a memory leak?

> + }
> +
> + pm_runtime_set_autosuspend_delay(&pdev->dev, 10000);
> + pm_runtime_use_autosuspend(&pdev->dev);
> + pm_runtime_enable(&pdev->dev);
> + return 0;

err:
kree(adata)
return ret;
?


> static const struct snd_pcm_hardware acp3x_pcm_hardware_playback = {
> .info = SNDRV_PCM_INFO_INTERLEAVED |
> SNDRV_PCM_INFO_BLOCK_TRANSFER |
> @@ -279,7 +261,11 @@ static int acp3x_dma_open(struct snd_soc_component *component,
> struct snd_pcm_substream *substream)
> {
> int ret = 0;
> +

newline?

> -
> static const struct snd_soc_component_driver acp3x_i2s_component = {
> .name = DRV_NAME,
> .open = acp3x_dma_open,
> @@ -619,6 +415,9 @@ static int acp3x_audio_probe(struct platform_device *pdev)
> return -ENODEV;
> }
> irqflags = *((unsigned int *)(pdev->dev.platform_data));
> + adata = devm_kzalloc(&pdev->dev, sizeof(*adata), GFP_KERNEL);
> + if (!adata)
> + return -ENOMEM;
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (!res) {
> @@ -626,10 +425,6 @@ static int acp3x_audio_probe(struct platform_device *pdev)
> return -ENODEV;
> }
>
> - adata = devm_kzalloc(&pdev->dev, sizeof(*adata), GFP_KERNEL);
> - if (!adata)
> - return -ENOMEM;
> -

that part is hard to review with diff, please double-check the changes.

\
 
 \ /
  Last update: 2019-11-07 18:06    [W:0.110 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site