Re: [PATCH] ASoC: cs35l56-shared-test: Fix possible null pointer dereference
From: Richard Fitzgerald
Date: Mon May 25 2026 - 05:50:41 EST
On 23/05/2026 10:15 pm, Ethan Tidmore wrote:
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.
Signed-off-by: Ethan Tidmore <ethantidmore06@xxxxxxxxx>
---
sound/soc/codecs/cs35l56-shared-test.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/sound/soc/codecs/cs35l56-shared-test.c b/sound/soc/codecs/cs35l56-shared-test.c
index 5b2b915559a9..4f52c8a192e5 100644
--- a/sound/soc/codecs/cs35l56-shared-test.c
+++ b/sound/soc/codecs/cs35l56-shared-test.c
@@ -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);