From: Ryder Lee <ryder.lee@mediatek.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: alsa-devel@alsa-project.org, linux-mediatek@lists.infradead.org
Subject: Re: [bug report] ASoC: mediatek: modify MT2701 AFE driver to adapt mfd device
Date: Mon, 22 Jan 2018 19:38:12 +0800 [thread overview]
Message-ID: <1516621092.30761.3.camel@mtkswgap22> (raw)
In-Reply-To: <20180122100138.GA20468@mwanda>
On Mon, 2018-01-22 at 13:01 +0300, Dan Carpenter wrote:
> Hello Ryder Lee,
>
> The patch dfa3cbb83e09: "ASoC: mediatek: modify MT2701 AFE driver to
> adapt mfd device" from Jan 4, 2018, leads to the following static
> checker warning:
>
> sound/soc/mediatek/mt2701/mt2701-afe-pcm.c:1535 mt2701_afe_pcm_dev_probe()
> error: double free of 'component'
>
> sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
> 1509 pm_runtime_get_sync(dev);
> 1510
> 1511 ret = snd_soc_register_platform(dev, &mtk_afe_pcm_platform);
> 1512 if (ret) {
> 1513 dev_warn(dev, "err_platform\n");
> 1514 goto err_platform;
> 1515 }
> 1516
> 1517 ret = snd_soc_add_component(dev, component,
> ^^^^^^^^^
> snd_soc_add_component() frees "component" on error. This seems like a
> layering violation to me, and it naturally leads to bugs like this.
>
> 1518 &mt2701_afe_pcm_dai_component,
> 1519 mt2701_afe_pcm_dais,
> 1520 ARRAY_SIZE(mt2701_afe_pcm_dais));
> 1521 if (ret) {
> 1522 dev_warn(dev, "err_dai_component\n");
> 1523 goto err_dai_component;
> 1524 }
> 1525
> 1526 return 0;
> 1527
> 1528 err_dai_component:
> 1529 snd_soc_unregister_platform(dev);
> 1530 err_platform:
> 1531 pm_runtime_put_sync(dev);
> 1532 err_pm_disable:
> 1533 pm_runtime_disable(dev);
> 1534 err_init_clock:
> 1535 kfree(component);
> ^^^^^^^^^
> Double free
Thanks for catching that. I've just sent a fixup patch.
Ryder
prev parent reply other threads:[~2018-01-22 11:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-22 10:01 [bug report] ASoC: mediatek: modify MT2701 AFE driver to adapt mfd device Dan Carpenter
2018-01-22 11:38 ` Ryder Lee [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1516621092.30761.3.camel@mtkswgap22 \
--to=ryder.lee@mediatek.com \
--cc=alsa-devel@alsa-project.org \
--cc=dan.carpenter@oracle.com \
--cc=linux-mediatek@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox