Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e22bd1d9 authored by Kamil Duljas's avatar Kamil Duljas Committed by Greg Kroah-Hartman
Browse files

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



[ Upstream commit f8ba14b780273fd290ddf7ee0d7d7decb44cc365 ]

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: default avatarKamil Duljas <kamil.duljas@gmail.com>
Reviewed-by: default avatarAmadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20231116224112.2209-2-kamil.duljas@gmail.com


Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 16ae3132
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -1450,6 +1450,7 @@ int skl_platform_register(struct device *dev)
		dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
		dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
				sizeof(skl_platform_dai), GFP_KERNEL);
				sizeof(skl_platform_dai), GFP_KERNEL);
		if (!dais) {
		if (!dais) {
			kfree(skl->dais);
			ret = -ENOMEM;
			ret = -ENOMEM;
			goto err;
			goto err;
		}
		}
@@ -1462,8 +1463,10 @@ int skl_platform_register(struct device *dev)


	ret = devm_snd_soc_register_component(dev, &skl_component,
	ret = devm_snd_soc_register_component(dev, &skl_component,
					 skl->dais, num_dais);
					 skl->dais, num_dais);
	if (ret)
	if (ret) {
		kfree(skl->dais);
		dev_err(dev, "soc component registration failed %d\n", ret);
		dev_err(dev, "soc component registration failed %d\n", ret);
	}
err:
err:
	return ret;
	return ret;
}
}