Skip to contentSkip to conversation

firmware: cs_dsp: Move lockdep asserts to avoid potential null pointer

PATCH In review Charles Keepax 2 participants 2 messages Nov 30, 2021 – Dec 1, 2021 Cirrus logic DSP firmware driver

lore
Share & tools
lore

Charles Keepax

author maintainer
#0 lore raw

PATCH 1/1 firmware: cs_dsp: Move lockdep asserts to avoid potential null pointer

Move the lockdep asserts until after the ctl pointer has been checked for NULL, to avoid potentially NULL pointer dereferences.

Fixes fb2f364fb5b9 ("firmware: cs_dsp: Add lockdep asserts to interface functions")
---
 drivers/firmware/cirrus/cs_dsp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/firmware/cirrus/cs_dsp.c +4 -4
index 3814cbba0a544..5af8171d6cedf 100644
@@ -759,11 +759,11 @@ int cs_dsp_coeff_write_ctrl(struct cs_dsp_coeff_ctl *ctl,
 {
 	int ret = 0;
 
-	lockdep_assert_held(&ctl->dsp->pwr_lock);
-
 	if (!ctl)
 		return -ENOENT;
 
+	lockdep_assert_held(&ctl->dsp->pwr_lock);
+
 	if (len + off * sizeof(u32) > ctl->len)
 		return -EINVAL;
 
@@ -827,11 +827,11 @@ int cs_dsp_coeff_read_ctrl(struct cs_dsp_coeff_ctl *ctl,
 {
 	int ret = 0;
 
-	lockdep_assert_held(&ctl->dsp->pwr_lock);
-
 	if (!ctl)
 		return -ENOENT;
 
+	lockdep_assert_held(&ctl->dsp->pwr_lock);
+
 	if (len + off * sizeof(u32) > ctl->len)
 		return -EINVAL;
 
Signature · 1 line
2.11.0
#1 lore raw
Quoted 4 lines · Charles Keepax

Move the lockdep asserts until after the ctl pointer has been checked for NULL, to avoid potentially NULL pointer dereferences.

Applied to

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

Thanks!

[1/1] firmware: cs_dsp: Move lockdep asserts to avoid potential null pointer

      commit: 043c0a6278ca443b1835726239dc2814c1313a9e

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