Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: Intel: Skylake: mem leak in skl register function

skl_platform_register() uses krealloc. When krealloc is fail,
then previous memory is not freed. The leak is also when soc
component registration failed.

Signed-off-by: Kamil Duljas <kamil.duljas@gmail.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20231116224112.2209-2-kamil.duljas@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Kamil Duljas and committed by
Mark Brown
f8ba14b7 31e721fb

+4 -1
+4 -1
sound/soc/intel/skylake/skl-pcm.c
··· 1464 1464 dais = krealloc(skl->dais, sizeof(skl_fe_dai) + 1465 1465 sizeof(skl_platform_dai), GFP_KERNEL); 1466 1466 if (!dais) { 1467 + kfree(skl->dais); 1467 1468 ret = -ENOMEM; 1468 1469 goto err; 1469 1470 } ··· 1477 1476 1478 1477 ret = devm_snd_soc_register_component(dev, &skl_component, 1479 1478 skl->dais, num_dais); 1480 - if (ret) 1479 + if (ret) { 1480 + kfree(skl->dais); 1481 1481 dev_err(dev, "soc component registration failed %d\n", ret); 1482 + } 1482 1483 err: 1483 1484 return ret; 1484 1485 }