Skip to content

Commit 043c0a6

Browse files
charleskeepaxbroonie
authored andcommitted
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") 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> Link: https://lore.kernel.org/r/20211130102842.26410-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 10b155f commit 043c0a6

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/firmware/cirrus/cs_dsp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -759,11 +759,11 @@ int cs_dsp_coeff_write_ctrl(struct cs_dsp_coeff_ctl *ctl,
759759
{
760760
int ret = 0;
761761

762-
lockdep_assert_held(&ctl->dsp->pwr_lock);
763-
764762
if (!ctl)
765763
return -ENOENT;
766764

765+
lockdep_assert_held(&ctl->dsp->pwr_lock);
766+
767767
if (len + off * sizeof(u32) > ctl->len)
768768
return -EINVAL;
769769

@@ -827,11 +827,11 @@ int cs_dsp_coeff_read_ctrl(struct cs_dsp_coeff_ctl *ctl,
827827
{
828828
int ret = 0;
829829

830-
lockdep_assert_held(&ctl->dsp->pwr_lock);
831-
832830
if (!ctl)
833831
return -ENOENT;
834832

833+
lockdep_assert_held(&ctl->dsp->pwr_lock);
834+
835835
if (len + off * sizeof(u32) > ctl->len)
836836
return -EINVAL;
837837

0 commit comments

Comments
 (0)