From 865df9cb122d9e5ecbbb7056f2c9c64933bf8dd0 Mon Sep 17 00:00:00 2001 From: Chuansheng Liu Date: Wed, 26 Dec 2012 00:56:05 +0800 Subject: ASoC: core: fix the memory leak in case of device_add() failure After called device_initialize(), even device_add() returns error, we still need use the put_device() to release the reference to call rtd_release(), which will do the free() action. Signed-off-by: liu chuansheng Signed-off-by: Mark Brown --- sound/soc/soc-core.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'sound') diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 29046e750ad7..f7551c1c827c 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -1255,6 +1255,8 @@ static int soc_post_component_init(struct snd_soc_card *card, INIT_LIST_HEAD(&rtd->dpcm[SNDRV_PCM_STREAM_CAPTURE].fe_clients); ret = device_add(rtd->dev); if (ret < 0) { + /* calling put_device() here to free the rtd->dev */ + put_device(rtd->dev); dev_err(card->dev, "ASoC: failed to register runtime device: %d\n", ret); return ret; -- cgit v1.2.3