]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
regmap: kunit: Fix memory leaks in gen_regmap() and gen_raw_regmap()
authorRichard Fitzgerald <rf@opensource.cirrus.com>
Thu, 11 Apr 2024 10:37:24 +0000 (11:37 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Aug 2024 13:34:05 +0000 (15:34 +0200)
commit9a3f1490f9b2b7b4d484d032dd0f13296ad59e08
treef9eb7fab91b3d59378c6cef1e936cd95212a4203
parent9bd6911af5224834d8592831de40356b64873fa4
regmap: kunit: Fix memory leaks in gen_regmap() and gen_raw_regmap()

[ Upstream commit c3820641da87442251e0c00b6874ef1022da8f58 ]

- Use kunit_kcalloc() to allocate the defaults table so that it will be
  freed when the test case ends.
- kfree() the buf and *data buffers on the error paths.
- Use kunit_add_action_or_reset() instead of kunit_add_action() so that
  if it fails it will call regmap_exit().

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://msgid.link/r/20240411103724.54063-1-rf@opensource.cirrus.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/base/regmap/regmap-kunit.c