From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kuninori Morimoto Subject: [PATCH] soc-core: don't call kfree() for component Date: Mon, 19 Mar 2018 07:27:17 +0000 Message-ID: <87efkgttmo.wl%kuninori.morimoto.gx@renesas.com> Mime-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from relmlie1.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa0.perex.cz (Postfix) with ESMTP id 4CD73267299 for ; Mon, 19 Mar 2018 08:27:20 +0100 (CET) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Mark Brown Cc: Linux-ALSA , Jernej Skrabec List-Id: alsa-devel@alsa-project.org From: Kuninori Morimoto When driver register its component to ALSA SoC, almost all drivers are using snd_soc_register_component(), but soc-generic-dmaengine-pcm is using snd_soc_add_component(). Existing component function had been assumed that registered component was allocated, and it calling kfree() for it. But, the user who used snd_soc_add_component() doesn't. This patch uses devm_kzalloc() instead of kzalloc() for component, and doesn't call kree() anymore. This patch fixes commit be7ee5f32a9a ("ASoC: soc-generic-dmaengine-pcm: replace platform to component"). Allwinner H3 SoC will crash without this patch. Thanks Jernej report. Reported-by: Jernej Skrabec Signed-off-by: Kuninori Morimoto Tested-by: Jernej Skrabec --- sound/soc/soc-core.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index c0edac8..4a8de23 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -3476,7 +3476,6 @@ int snd_soc_add_component(struct device *dev, err_cleanup: snd_soc_component_cleanup(component); err_free: - kfree(component); return ret; } EXPORT_SYMBOL_GPL(snd_soc_add_component); @@ -3488,7 +3487,7 @@ int snd_soc_register_component(struct device *dev, { struct snd_soc_component *component; - component = kzalloc(sizeof(*component), GFP_KERNEL); + component = devm_kzalloc(dev, sizeof(*component), GFP_KERNEL); if (!component) return -ENOMEM; @@ -3523,7 +3522,6 @@ static int __snd_soc_unregister_component(struct device *dev) if (found) { snd_soc_component_cleanup(component); - kfree(component); } return found; -- 1.9.1