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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Signed-off-by: Charles Keepax <ckeepax@xxxxxxxxxxxxxxxxxxxxx>
---
 drivers/firmware/cirrus/cs_dsp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

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;
 
-- 
2.11.0




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux