linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "He, Bo" <bo.he@intel.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.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>,
	"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: Tue, 6 Nov 2018 00:58:30 +0000	[thread overview]
Message-ID: <CD6925E8781EFD4D8E11882D20FC406D529FE5A9@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <f2e3ffeb-12bd-d60e-e96a-8fa00a17844f@linux.intel.com>

Hi, 
	I submit the patch based on tag v4.19.

-----Original Message-----
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> 
Sent: Tuesday, November 6, 2018 1:02 AM
To: He, Bo <bo.he@intel.com>; alsa-devel@alsa-project.org; linux-kernel@vger.kernel.org
Cc: liam.r.girdwood@linux.intel.com; perex@perex.cz; 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; 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


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;
>   }

  reply	other threads:[~2018-11-06  0:58 UTC|newest]

Thread overview: 5+ 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 17:01 ` [alsa-devel] " Pierre-Louis Bossart
2018-11-06  0:58   ` He, Bo [this message]
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=CD6925E8781EFD4D8E11882D20FC406D529FE5A9@SHSMSX104.ccr.corp.intel.com \
    --to=bo.he@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=divya1.prakash@intel.com \
    --cc=guneshwor.o.singh@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=perex@perex.cz \
    --cc=pierre-louis.bossart@linux.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 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).