rk3368: dvfs: avoid null-pointer dereference in dvfs_get_temp
authorXiao Feng <xf@rock-chips.com>
Thu, 26 Mar 2015 02:38:56 +0000 (10:38 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Fri, 27 Mar 2015 01:39:12 +0000 (09:39 +0800)
Signed-off-by: Xiao Feng <xf@rock-chips.com>
arch/arm/mach-rockchip/dvfs.c

index 382e37fdc0f47b3805a312ff94e0f62be542de7d..f800200f481a3ea9358fea86c4c3ca22ebbb1e87 100644 (file)
@@ -44,11 +44,15 @@ struct regulator *vdd_gpu_regulator;
 
 static int dvfs_get_temp(int chn)
 {
-       int temp = 0;
+       int temp = INVALID_TEMP;
 
 #if IS_ENABLED(CONFIG_ROCKCHIP_THERMAL)
        int read_back = 0;
 
+       if (clk_cpu_bl_dvfs_node == NULL ||
+           IS_ERR_OR_NULL(clk_cpu_bl_dvfs_node->vd->regulator))
+               return temp;
+
        mutex_lock(&clk_cpu_bl_dvfs_node->vd->mutex);
        read_back = dvfs_regulator_get_voltage(
                clk_cpu_bl_dvfs_node->vd->regulator);