]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ASoC: wcd934x: fix error handling in wcd934x_codec_parse_data()
authorMa Ke <make24@iscas.ac.cn>
Tue, 23 Sep 2025 06:52:12 +0000 (14:52 +0800)
committerMark Brown <broonie@kernel.org>
Tue, 23 Sep 2025 08:39:31 +0000 (10:39 +0200)
commit4e65bda8273c938039403144730923e77916a3d7
treeb1a9ad5d499d4cccf3b1d851b7af599ce302b689
parent87cab86925b7fa4c1c977bc191ac549a3b23f0ea
ASoC: wcd934x: fix error handling in wcd934x_codec_parse_data()

wcd934x_codec_parse_data() contains a device reference count leak in
of_slim_get_device() where device_find_child() increases the reference
count of the device but this reference is not properly decreased in
the success path. Add put_device() in wcd934x_codec_parse_data() and
add devm_add_action_or_reset() in the probe function, which ensures
that the reference count of the device is correctly managed.

Memory leak in regmap_init_slimbus() as the allocated regmap is not
released when the device is removed. Using devm_regmap_init_slimbus()
instead of regmap_init_slimbus() to ensure automatic regmap cleanup on
device removal.

Calling path: of_slim_get_device() -> of_find_slim_device() ->
device_find_child(). As comment of device_find_child() says, 'NOTE:
you will need to drop the reference with put_device() after use.'.

Found by code review.

Cc: stable@vger.kernel.org
Fixes: a61f3b4f476e ("ASoC: wcd934x: add support to wcd9340/wcd9341 codec")
Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Link: https://patch.msgid.link/20250923065212.26660-1-make24@iscas.ac.cn
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/codecs/wcd934x.c