Skip to content

Commit 0be4438

Browse files
finley1226numbqq
authored andcommitted
soc: rockchip: system_monitor: Fix NULL pointer dereference when register
If system monitor is disabled or the driver is failed to probe, a NULL pointer deference will happen as follow. Unable to handle kernel NULL pointer dereference at virtual address 00000048 pgd = ffffff80096b9000 [00000048] *pgd=00000000f6ffe003, *pud=00000000f6ffe003, *pmd=0000000000000000 Internal error: Oops: 96000005 [#1] PREEMPT SMP Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.4.167 torvalds#86 Hardware name: Rockchip RK3399 Excavator Board edp avb (Android) (DT) task: ffffffc00a368000 task.stack: ffffffc00a344000 PC is at rockchip_system_monitor_register+0x618/0x838 LR is at rockchip_system_monitor_register+0x778/0x838 pc : [<ffffff8008447dec>] lr : [<ffffff8008447f4c>] pstate: 80400145 ... 7700: ffffffc0f13c4140 fffffffffffffffd 0101010101010101 000000000000000b 7720: 20303030353d7473 3d74696d696c5f6c [<ffffff8008447dec>] rockchip_system_monitor_register+0x618/0x838 [<ffffff800884f87c>] cpufreq_init+0x388/0x3d8 [<ffffff8008846ee4>] cpufreq_online+0x1b0/0x66c [<ffffff8008847440>] cpufreq_add_dev+0x3c/0x94 [<ffffff8008544810>] subsys_interface_register+0xd4/0xf8 [<ffffff8008847648>] cpufreq_register_driver+0x10c/0x1a8 [<ffffff800884f998>] dt_cpufreq_probe+0xcc/0xe8 [<ffffff8008547bf8>] platform_drv_probe+0x54/0xa8 [<ffffff8008545fb4>] driver_probe_device+0x188/0x26c [<ffffff80085461c8>] __device_attach_driver+0x60/0x9c [<ffffff80085444c0>] bus_for_each_drv+0x9c/0xbc [<ffffff8008545d90>] __device_attach+0xc4/0x12c [<ffffff800854633c>] device_initial_probe+0x10/0x18 [<ffffff80085453b8>] bus_probe_device+0x2c/0x8c [<ffffff800854356c>] device_add+0x424/0x51c [<ffffff80085479c0>] platform_device_add+0xa0/0x1e8 [<ffffff800854840c>] platform_device_register_full+0xa4/0xe4 [<ffffff8009218c50>] rockchip_cpufreq_driver_init+0xc4/0x328 [<ffffff800808356c>] do_one_initcall+0x188/0x1a4 [<ffffff80091e0e90>] kernel_init_freeable+0x228/0x22c [<ffffff8008c1d4e8>] kernel_init+0x10/0xf8 [<ffffff80080832a0>] ret_from_fork+0x10/0x30 Change-Id: I8743040d15d594dbef67439b18782e6f16e9683a Signed-off-by: Finley Xiao <finley.xiao@rock-chips.com>
1 parent dc59d56 commit 0be4438

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/soc/rockchip/rockchip_system_monitor.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,9 @@ rockchip_system_monitor_register(struct device *dev,
10311031
struct devfreq *devfreq;
10321032
int ret;
10331033

1034+
if (!system_monitor)
1035+
return ERR_PTR(-ENOMEM);
1036+
10341037
info = kzalloc(sizeof(*info), GFP_KERNEL);
10351038
if (!info)
10361039
return ERR_PTR(-ENOMEM);
@@ -1063,7 +1066,7 @@ rockchip_system_monitor_register(struct device *dev,
10631066
kfree(info);
10641067
return ERR_PTR(-EINVAL);
10651068
}
1066-
EXPORT_SYMBOL_GPL(rockchip_system_monitor_register);
1069+
EXPORT_SYMBOL(rockchip_system_monitor_register);
10671070

10681071
void rockchip_system_monitor_unregister(struct monitor_dev_info *info)
10691072
{
@@ -1443,6 +1446,8 @@ static int rockchip_system_monitor_probe(struct platform_device *pdev)
14431446
if (fb_register_client(&rockchip_monitor_fb_nb))
14441447
dev_err(dev, "failed to register fb nb\n");
14451448

1449+
dev_info(dev, "system monitor probe\n");
1450+
14461451
return 0;
14471452
}
14481453

0 commit comments

Comments
 (0)