soc: rockchip_system_monitor: fix potential NULL ptr deref

Signed-off-by: jensen <jensenhuang@friendlyarm.com>
This commit is contained in:
jensen
2023-09-15 16:30:19 +08:00
committed by Mecid Urganci
parent 3bdb6023e2
commit 208939a3c9

View File

@@ -1186,6 +1186,11 @@ rockchip_system_monitor_wide_temp_init(struct monitor_dev_info *info)
info->is_low_temp = true;
}
if (!system_monitor->tz) {
dev_err(info->dev, "thermal zone is NULL\n");
return;
}
ret = thermal_zone_get_temp(system_monitor->tz, &temp);
if (ret || temp == THERMAL_TEMP_INVALID) {
dev_err(info->dev,
@@ -1373,6 +1378,11 @@ rockchip_system_monitor_register(struct device *dev,
if (!devp)
return ERR_PTR(-EINVAL);
if (!devp->check_rate_volt) {
dev_warn(dev, "using default check_rate_volt\n");
devp->check_rate_volt = rockchip_monitor_check_rate_volt;
}
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return ERR_PTR(-ENOMEM);