From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: "He, Bo" <bo.he@intel.com>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "kuninori.morimoto.gx@renesas.com"
<kuninori.morimoto.gx@renesas.com>,
"Periyasamy, SriramX" <sriramx.periyasamy@intel.com>,
"Diwakar, Praveen" <praveen.diwakar@intel.com>,
"Zhang, Yanmin" <yanmin.zhang@intel.com>,
"Singh, Guneshwor O" <guneshwor.o.singh@intel.com>,
"tiwai@suse.com" <tiwai@suse.com>,
"Prakash, Divya1" <divya1.prakash@intel.com>,
"liam.r.girdwood@linux.intel.com"
<liam.r.girdwood@linux.intel.com>,
"guruprasadx.pawse@intel.com" <guruprasadx.pawse@intel.com>,
"Ughreja, Rakesh A" <rakesh.a.ughreja@intel.com>,
"Kesapragada,
Pardha Saradhi" <pardha.saradhi.kesapragada@intel.com>,
"Kale, Sanyog R" <sanyog.r.kale@intel.com>
Subject: Re: [PATCH] fix the kernel panic due to wrong use the dev memory API
Date: Mon, 5 Nov 2018 11:01:38 -0600 [thread overview]
Message-ID: <f2e3ffeb-12bd-d60e-e96a-8fa00a17844f@linux.intel.com> (raw)
In-Reply-To: <CD6925E8781EFD4D8E11882D20FC406D529FE3B6@SHSMSX104.ccr.corp.intel.com>
On 11/5/18 2:29 AM, He, Bo wrote:
> skl->dais is allocated with devm_kcalloc, can't free with
> the krealloc. Memory allocated with devm API is automatically freed
> on driver detach, Like all other devres resources.
>
> Refer to drivers/base/devres.c devm_kmalloc for more details.
What code are you looking at?
I see this in the Mark's tree
int skl_platform_register(struct device *dev)
{
int ret;
struct snd_soc_dai_driver *dais;
int num_dais = ARRAY_SIZE(skl_platform_dai);
struct hdac_bus *bus = dev_get_drvdata(dev);
struct skl *skl = bus_to_skl(bus);
INIT_LIST_HEAD(&skl->ppl_list);
INIT_LIST_HEAD(&skl->bind_list);
skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai),
GFP_KERNEL);
if (!skl->dais) {
ret = -ENOMEM;
goto err;
}
if (!skl->use_tplg_pcm) {
dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
sizeof(skl_platform_dai), GFP_KERNEL);
No trace of devm as you mention it? I checked the Chrome tree as well
and it's not there.
What am I missing?
>
> Signed-off-by: he, bo <bo.he@intel.com>
> ---
> sound/soc/intel/skylake/skl-pcm.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
> index 823e391..928d314 100644
> --- a/sound/soc/intel/skylake/skl-pcm.c
> +++ b/sound/soc/intel/skylake/skl-pcm.c
> @@ -1438,7 +1438,8 @@ int skl_platform_register(struct device *dev)
> }
>
> if (!skl->use_tplg_pcm) {
> - dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
> + devm_kfree(dev, skl->dais);
> + dais = devm_kcalloc(dev, skl->dais, sizeof(skl_fe_dai) +
> sizeof(skl_platform_dai), GFP_KERNEL);
> if (!dais) {
> ret = -ENOMEM;
> @@ -1472,7 +1473,5 @@ int skl_platform_unregister(struct device *dev)
> }
> }
>
> - kfree(skl->dais);
> -
> return 0;
> }
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
WARNING: multiple messages have this Message-ID (diff)
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: "He, Bo" <bo.he@intel.com>,
"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "liam.r.girdwood@linux.intel.com"
<liam.r.girdwood@linux.intel.com>,
"perex@perex.cz" <perex@perex.cz>,
"tiwai@suse.com" <tiwai@suse.com>,
"Singh, Guneshwor O" <guneshwor.o.singh@intel.com>,
"Periyasamy, SriramX" <sriramx.periyasamy@intel.com>,
"Kale, Sanyog R" <sanyog.r.kale@intel.com>,
"Kesapragada,
Pardha Saradhi" <pardha.saradhi.kesapragada@intel.com>,
"kuninori.morimoto.gx@renesas.com"
<kuninori.morimoto.gx@renesas.com>,
"guruprasadx.pawse@intel.com" <guruprasadx.pawse@intel.com>,
"Ughreja, Rakesh A" <rakesh.a.ughreja@intel.com>,
"Prakash, Divya1" <divya1.prakash@intel.com>,
"Diwakar, Praveen" <praveen.diwakar@intel.com>,
"Zhang, Yanmin" <yanmin.zhang@intel.com>
Subject: Re: [alsa-devel] [PATCH] fix the kernel panic due to wrong use the dev memory API
Date: Mon, 5 Nov 2018 11:01:38 -0600 [thread overview]
Message-ID: <f2e3ffeb-12bd-d60e-e96a-8fa00a17844f@linux.intel.com> (raw)
In-Reply-To: <CD6925E8781EFD4D8E11882D20FC406D529FE3B6@SHSMSX104.ccr.corp.intel.com>
On 11/5/18 2:29 AM, He, Bo wrote:
> skl->dais is allocated with devm_kcalloc, can't free with
> the krealloc. Memory allocated with devm API is automatically freed
> on driver detach, Like all other devres resources.
>
> Refer to drivers/base/devres.c devm_kmalloc for more details.
What code are you looking at?
I see this in the Mark's tree
int skl_platform_register(struct device *dev)
{
int ret;
struct snd_soc_dai_driver *dais;
int num_dais = ARRAY_SIZE(skl_platform_dai);
struct hdac_bus *bus = dev_get_drvdata(dev);
struct skl *skl = bus_to_skl(bus);
INIT_LIST_HEAD(&skl->ppl_list);
INIT_LIST_HEAD(&skl->bind_list);
skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai),
GFP_KERNEL);
if (!skl->dais) {
ret = -ENOMEM;
goto err;
}
if (!skl->use_tplg_pcm) {
dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
sizeof(skl_platform_dai), GFP_KERNEL);
No trace of devm as you mention it? I checked the Chrome tree as well
and it's not there.
What am I missing?
>
> Signed-off-by: he, bo <bo.he@intel.com>
> ---
> sound/soc/intel/skylake/skl-pcm.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
> index 823e391..928d314 100644
> --- a/sound/soc/intel/skylake/skl-pcm.c
> +++ b/sound/soc/intel/skylake/skl-pcm.c
> @@ -1438,7 +1438,8 @@ int skl_platform_register(struct device *dev)
> }
>
> if (!skl->use_tplg_pcm) {
> - dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
> + devm_kfree(dev, skl->dais);
> + dais = devm_kcalloc(dev, skl->dais, sizeof(skl_fe_dai) +
> sizeof(skl_platform_dai), GFP_KERNEL);
> if (!dais) {
> ret = -ENOMEM;
> @@ -1472,7 +1473,5 @@ int skl_platform_unregister(struct device *dev)
> }
> }
>
> - kfree(skl->dais);
> -
> return 0;
> }
next prev parent reply other threads:[~2018-11-05 17:01 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-05 8:29 [PATCH] fix the kernel panic due to wrong use the dev memory API He, Bo
2018-11-05 10:38 ` kbuild test robot
2018-11-05 10:38 ` kbuild test robot
2018-11-05 17:01 ` Pierre-Louis Bossart [this message]
2018-11-05 17:01 ` [alsa-devel] " Pierre-Louis Bossart
2018-11-06 0:58 ` He, Bo
2018-11-06 14:39 ` Pierre-Louis Bossart
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=f2e3ffeb-12bd-d60e-e96a-8fa00a17844f@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=bo.he@intel.com \
--cc=divya1.prakash@intel.com \
--cc=guneshwor.o.singh@intel.com \
--cc=guruprasadx.pawse@intel.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=liam.r.girdwood@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pardha.saradhi.kesapragada@intel.com \
--cc=praveen.diwakar@intel.com \
--cc=rakesh.a.ughreja@intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=sriramx.periyasamy@intel.com \
--cc=tiwai@suse.com \
--cc=yanmin.zhang@intel.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.