Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1938789imu; Tue, 6 Nov 2018 06:42:33 -0800 (PST) X-Google-Smtp-Source: AJdET5c+Bq0Ql4X9kUXGc0Fgp7KN1vGbI7GkGPZSbXF5fpXKzFvVm5GWJ3jkL5EvjR74ZMWsXQhB X-Received: by 2002:a63:be4d:: with SMTP id g13mr24218700pgo.378.1541515353875; Tue, 06 Nov 2018 06:42:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541515353; cv=none; d=google.com; s=arc-20160816; b=D50fes2k9xegw2OggmMx5S1Ile9yCKpNdO2A5aCkoKLpbGBt2FyrfHEr1gX6n8IVXS U9JMQuPh20ITTAPktmL9IdjriuXv+zs9wDcZupfRyro6GqRLGpBxGqx689zx5p8MZDU0 +8F/BI20cVSUdkA+XnUvixyd6+Hlvwv++FSHzUiiG2HQcYTI2I6FXWDwKwtj2yljenOD M7btunQ3Pyyuk5m8NEJochZXTyFhqEzCYbSm1mRhKGuJlHQ9715MPAxXib0RGtVF7vpm L5g4hUTgqIZaKTC3nn8528dZbhSI4O9Y7L/6/sn5NGhVdWK3zPfgN+yJM/6xn5QYB21+ YG9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=xGCM6y6dalHJYbhuzccgFkMpxebo8hg14F0OcWYF5I8=; b=rAUsyNU3h9Q/2tqx9Z/TK3W1bH9N/dkzzb6ocoDZpucS6WE7Um5Fu8Jz3YUwTM9uox CDRbmNg5VLpD21IeoDBMf60CwG/Pm5ofbTrC/4cQLdLe/CcQe7NfkdwhBldfGiubTiU5 /4NtGnc2EGcZ/yN0s7ywz/qFKMqooM1pTma24kHukkrCd70QVPEr8xR7KYABCVpDch5n uyhCZF4o0QUJLaq9hHXY/MPAPX4MyzhWvC3PGypWUf2MBQtg4qoFMblIF3G+S86Nm79t YwsSQWj/n3ECNFg89D5+EgMCy2lfufb/6nXsCXJBJIqCppnn5Q0pr/RKuFJMNrNL6t26 76Yg== 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 d4-v6si30238002pla.203.2018.11.06.06.42.07; Tue, 06 Nov 2018 06:42:33 -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 S2388915AbeKGAFU (ORCPT + 99 others); Tue, 6 Nov 2018 19:05:20 -0500 Received: from mga04.intel.com ([192.55.52.120]:6844 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388754AbeKGAFT (ORCPT ); Tue, 6 Nov 2018 19:05:19 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Nov 2018 06:39:48 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,472,1534834800"; d="scan'208";a="105851507" Received: from linux.intel.com ([10.54.29.200]) by orsmga001.jf.intel.com with ESMTP; 06 Nov 2018 06:39:48 -0800 Received: from cjloo-mobl.amr.corp.intel.com (unknown [10.255.84.97]) by linux.intel.com (Postfix) with ESMTP id D063A580384; Tue, 6 Nov 2018 06:39:46 -0800 (PST) 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" , "Ughreja, Rakesh A" , "Prakash, Divya1" , "Diwakar, Praveen" , "Zhang, Yanmin" References: From: Pierre-Louis Bossart Message-ID: Date: Tue, 6 Nov 2018 08:39:46 -0600 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/5/18 6:58 PM, He, Bo wrote: > Hi, > I submit the patch based on tag v4.19. Please don't post on mailing lists. > > -----Original Message----- > From: Pierre-Louis Bossart > Sent: Tuesday, November 6, 2018 1:02 AM > 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 > 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? The code is completely identical in v4.19. skl->dais is allocated with kmemdup, which is a kmalloc+memcpy, i just don't understand what you are trying to fix. > > >> >> 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; >> }