Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp805245imu; Mon, 5 Nov 2018 09:02:32 -0800 (PST) X-Google-Smtp-Source: AJdET5da/HS34yHFBnNLr9Qkru+iCmFncbx0rSBaXSPylvDlyt9AQOC3rGclhHD92587PlfUyOdt X-Received: by 2002:a62:6c89:: with SMTP id h131-v6mr8282058pfc.12.1541437352822; Mon, 05 Nov 2018 09:02:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541437352; cv=none; d=google.com; s=arc-20160816; b=W9thVP5Ju57ph85iT9uO5kfLX1D2lnfJw+Y+aXCkmNsnajyIBh8PN5aNF96NjGI9mQ Pg9R/a93kbTdwQK7km53NPEI5IF+k1o71ulWqBiDR8jjz6YzWeCfYCnrgpIeNEGJd9nH vCGIAN0gWFxd6ZktGIHq6GfqZA7OKCJ3C5AtMpgtBzvfV1BUf77d0nvddUXqVeW8gxoc o9YsLfZpeuxZzu5YBmpXdsa3reThAcJGYfuiM4+D8Z7ftDPRdM3iGknnQ5kWD9ooPKNv PhP4yCJEAnJ/yM34zy6zBkTaR6CiJPa1ZajU4tjDcJ8mR2XMpOPCCOaj+iHOke1TszBP W+aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=53TjA2sFEn83jeItt/ZNPt1ADrWaVCZ1x4U7LMvynNc=; b=FutD2bpL8ic6aSaphDa17jBETgB4RjLSJAVKS9wFvkzJVMVcUKnbmP0XqK68C/kk96 d7iMmEsaIq9lZ7NnV40N4YDoFxveOY9cmtjaUGnlFi97BjT25qBJnOEV7YRE0a2Gpby/ Q7OPpRN5iXNt0pvZz8XKIyYr+D+lBRMFGGu0ATpnubGiXmQRj4fnlSVcNSE0J5Jz6+kE JfJiZqsOcmXxl5CUNKi9PTwfajk3j/djHMql/d5SfdQ+67a841ZDx7TowtCXkAgw/h2M rNdVdRH79Aakljj7PfmL3hOcAQTwZ+0EIzXWVtzJ+3yG/srm8yICbm0atVH+nfBRFje/ E9Vw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e92-v6si44030169pld.45.2018.11.05.09.02.15; Mon, 05 Nov 2018 09:02:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387684AbeKFCWZ (ORCPT + 99 others); Mon, 5 Nov 2018 21:22:25 -0500 Received: from mga06.intel.com ([134.134.136.31]:13575 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387458AbeKFCWZ (ORCPT ); Mon, 5 Nov 2018 21:22:25 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Nov 2018 09:01:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,468,1534834800"; d="scan'208";a="93821049" Received: from patelp1x-mobl3.amr.corp.intel.com (HELO [10.252.130.246]) ([10.252.130.246]) by FMSMGA003.fm.intel.com with ESMTP; 05 Nov 2018 09:01:39 -0800 Subject: Re: [alsa-devel] [PATCH] fix the kernel panic due to wrong use the dev memory API To: "He, Bo" , "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" , "Periyasamy, SriramX" , "Kale, Sanyog R" , "Kesapragada, Pardha Saradhi" , "kuninori.morimoto.gx@renesas.com" , "guruprasadx.pawse@intel.com" , "Ughreja, Rakesh A" , "Prakash, Divya1" , "Diwakar, Praveen" , "Zhang, Yanmin" References: From: Pierre-Louis Bossart Message-ID: Date: Mon, 5 Nov 2018 11:01:38 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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; > }