linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix the kernel panic due to wrong use the dev memory API
@ 2018-11-05  8:29 He, Bo
  2018-11-05 10:38 ` kbuild test robot
  2018-11-05 17:01 ` [alsa-devel] " Pierre-Louis Bossart
  0 siblings, 2 replies; 5+ messages in thread
From: He, Bo @ 2018-11-05  8:29 UTC (permalink / raw)
  To: alsa-devel, linux-kernel
  Cc: pierre-louis.bossart, liam.r.girdwood, perex, tiwai, Singh,
	Guneshwor O, Periyasamy, SriramX, Kale, Sanyog R, Kesapragada,
	Pardha Saradhi, kuninori.morimoto.gx, guruprasadx.pawse, Ughreja,
	Rakesh A, Prakash, Divya1, Diwakar, Praveen, Zhang, Yanmin

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.

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




^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-11-06 14:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2018-11-06 14:39     ` Pierre-Louis Bossart

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).