diff mbox series

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

Message ID 20211130102842.26410-1-ckeepax@opensource.cirrus.com (mailing list archive)
State Accepted
Commit 043c0a6278ca443b1835726239dc2814c1313a9e
Headers show
Series firmware: cs_dsp: Move lockdep asserts to avoid potential null pointer | expand

Commit Message

Charles Keepax Nov. 30, 2021, 10:28 a.m. UTC
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")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 drivers/firmware/cirrus/cs_dsp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Mark Brown Dec. 1, 2021, 6:32 p.m. UTC | #1
On Tue, 30 Nov 2021 10:28:42 +0000, Charles Keepax wrote:
> 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
diff mbox series

Patch

diff --git a/drivers/firmware/cirrus/cs_dsp.c b/drivers/firmware/cirrus/cs_dsp.c
index 3814cbba0a544..5af8171d6cedf 100644
--- a/drivers/firmware/cirrus/cs_dsp.c
+++ b/drivers/firmware/cirrus/cs_dsp.c
@@ -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;