]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ASoC: sma1307: Fix error handling in sma1307_setting_loaded()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 21 Mar 2025 14:35:25 +0000 (17:35 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 May 2025 09:13:47 +0000 (11:13 +0200)
commit63da47daf71c79cc2b312acd154615c8f0fb6aa0
treed3d095007507fb07465c5b886cfbfc992e36cde3
parent0c1baab4f052de1cf2313b4f7cb07ffc34bfc0a2
ASoC: sma1307: Fix error handling in sma1307_setting_loaded()

[ Upstream commit 012a6efcc805308b1d90a1056ba963eb08858645 ]

There are a couple bugs in this code:

1) The cleanup code calls kfree(sma1307->set.header) and
   kfree(sma1307->set.def) but those functions were allocated using
   devm_kzalloc().  It results in a double free.  Delete all these
   kfree() calls.

2) A missing call to kfree(data) if the checksum was wrong on this error
   path:
if ((sma1307->set.checksum >> 8) != SMA1307_SETTING_CHECKSUM) {
   Since the "data" pointer is supposed to be freed on every return, I
   changed that to use the __free(kfree) cleanup attribute.

Fixes: 0ec6bd16705f ("ASoC: sma1307: Add NULL check in sma1307_setting_loaded()")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/8d32dd96-1404-4373-9b6c-c612a9c18c4c@stanley.mountain
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/codecs/sma1307.c