lkml.org 
[lkml]   [2022]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] iio: vadc: Fix potential dereference of NULL pointer
Date
The return value of vadc_get_channel() needs to be checked
to avoid use of NULL pointer, which is followed by
the caller 'vadc_do_conversion' of function 'vadc_configure'.
Fix this by adding the null pointer check on prop
in function 'vadc_configure'.

Signed-off-by: Yongzhi Liu <lyz_cs@pku.edu.cn>
---
drivers/iio/adc/qcom-spmi-vadc.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c
index 34202ba..d99bd72 100644
--- a/drivers/iio/adc/qcom-spmi-vadc.c
+++ b/drivers/iio/adc/qcom-spmi-vadc.c
@@ -210,6 +210,9 @@ static int vadc_configure(struct vadc_priv *vadc,
u8 decimation, mode_ctrl;
int ret;

+ if (!prop)
+ return -ENODEV;
+
/* Mode selection */
mode_ctrl = (VADC_OP_MODE_NORMAL << VADC_OP_MODE_SHIFT) |
VADC_ADC_TRIM_EN | VADC_AMUX_TRIM_EN;
--
2.7.4
\
 
 \ /
  Last update: 2022-05-18 08:47    [W:0.090 / U:0.388 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site