]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ALSA: aoa: i2sbus: fix possible memory leak in i2sbus_add_dev()
authorYang Yingliang <yangyingliang@huawei.com>
Thu, 27 Oct 2022 01:34:38 +0000 (09:34 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Nov 2022 15:00:33 +0000 (00:00 +0900)
commitc7524279c8ddc7dbf3463bec70e0289097959944
treec7fcde9f42fa83c91e8836c14ee27de05426ba64
parentab6240cc56c9a6fe824e04f13e3ba0d26a260c8d
ALSA: aoa: i2sbus: fix possible memory leak in i2sbus_add_dev()

[ Upstream commit 4a4c8482e370d697738a78dcd7bf2780832cb712 ]

dev_set_name() in soundbus_add_one() allocates memory for name, it need be
freed when of_device_register() fails, call soundbus_dev_put() to give up
the reference that hold in device_initialize(), so that it can be freed in
kobject_cleanup() when the refcount hit to 0. And other resources are also
freed in i2sbus_release_dev(), so it can return 0 directly.

Fixes: f3d9478b2ce4 ("[ALSA] snd-aoa: add snd-aoa")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221027013438.991920-1-yangyingliang@huawei.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/aoa/soundbus/i2sbus/core.c