Skip to contentSkip to conversation

ASoC: cs35l56-shared-test: Fix possible null pointer dereference

PATCH In review Ethan Tidmore 3 participants 4 messages May 23 – May 26

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: cs35l56-shared-test: Fix possible null pointer dereference

The struct regmap_config is dereferenced before its check. Also, after it is checked priv->reg_offset is assigned to regmap_config->reg_base, making the removed line redundant.

Detected by Smatch:
sound/soc/codecs/cs35l56-shared-test.c:681 cs35l56_shared_test_case_base_init()
warn: variable dereferenced before check 'regmap_config' (see line 665)

Fixes a6f7c21accb5f ("ASoC: cs35l56-shared-test: Subtract reg_base offset in dummy regmap")
---
 sound/soc/codecs/cs35l56-shared-test.c | 1 -
 1 file changed, 1 deletion(-)
sound/soc/codecs/cs35l56-shared-test.c +0 -1
index 5b2b915559a9..4f52c8a192e5 100644
@@ -662,7 +662,6 @@ static int cs35l56_shared_test_case_base_init(struct kunit *test, u8 type, u8 re
 
 	test->priv = priv;
 	priv->test = test;
-	priv->reg_offset = regmap_config->reg_base;
 
 	/* Create dummy amp driver dev */
 	priv->amp_dev = faux_device_create("cs35l56_shared_test_drv", NULL, NULL);
Signature · 1 line
2.54.0
#1 lore raw
Quoted 9 lines · Ethan Tidmore

The struct regmap_config is dereferenced before its check. Also, after it is checked priv->reg_offset is assigned to regmap_config->reg_base, making the removed line redundant.

Detected by Smatch:
sound/soc/codecs/cs35l56-shared-test.c:681 cs35l56_shared_test_case_base_init()
warn: variable dereferenced before check 'regmap_config' (see line 665)

Fixes a6f7c21accb5f ("ASoC: cs35l56-shared-test: Subtract reg_base offset in dummy regmap")

If you apply this change on top of commit a6f7c21accb5f it would break the test because it removes the line instead of moving it to a different place.

Something weird has happened here. I already fixed this in V4 of the patch series. It turns out that V3 was already merged, but I didn't receive a merge notificiation. V4 has then been merged on top so Mark's for-7.2 and for-next contain the combination of V3 and V4 but this fix commit doesn't make sense for either version, only the final composite result.

Mark:
There isn't actually a bug here. regmap_config is always a valid pointer in the current code. The later NULL check is currently redundant.

I suggest (to avoid the confusion of which Fixes: SHA it should reference) this is just added to for-next as a cleanup (not a Fixes), since there's no bug.

Quoted 17 lines
---
  sound/soc/codecs/cs35l56-shared-test.c | 1 -
  1 file changed, 1 deletion(-)
sound/soc/codecs/cs35l56-shared-test.c +0 -1
index 5b2b915559a9..4f52c8a192e5 100644
@@ -662,7 +662,6 @@ static int cs35l56_shared_test_case_base_init(struct kunit *test, u8 type, u8 re
 
  	test->priv = priv;
  	priv->test = test;
-	priv->reg_offset = regmap_config->reg_base;
 
  	/* Create dummy amp driver dev */
  	priv->amp_dev = faux_device_create("cs35l56_shared_test_drv", NULL, NULL);
maintainer
#2 lore raw
Quoted 5 lines · Richard Fitzgerald

patch series. It turns out that V3 was already merged, but I didn't receive a merge notificiation. V4 has then been merged on top so Mark's for-7.2 and for-next contain the combination of V3 and V4 but this fix commit doesn't make sense for either version, only the final composite result.

You'll only get a notification for the most current version with my current tooling (people complained about getting notifications on old versions...) and if you resend quickly things might already be in my CI.

maintainer
#3 lore raw
In reply to Ethan Tidmore
Quoted 1 line · Ethan Tidmore

ASoC: cs35l56-shared-test: Fix possible null pointer dereference

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2

Thanks!

[1/1] ASoC: cs35l56-shared-test: Fix possible null pointer dereference

      https://git.kernel.org/broonie/sound/c/4fa26292e8dc

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark