Skip to content

Commit

Permalink
soc: rockchip: system_monitor: Fix NULL pointer dereference when regi…
Browse files Browse the repository at this point in the history
…ster

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 #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 <[email protected]>
  • Loading branch information
finley1226 committed Apr 29, 2019
1 parent e32b80a commit c43cd9e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/soc/rockchip/rockchip_system_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,9 @@ rockchip_system_monitor_register(struct device *dev,
struct devfreq *devfreq;
int ret;

if (!system_monitor)
return ERR_PTR(-ENOMEM);

info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
return ERR_PTR(-ENOMEM);
Expand Down Expand Up @@ -1063,7 +1066,7 @@ rockchip_system_monitor_register(struct device *dev,
kfree(info);
return ERR_PTR(-EINVAL);
}
EXPORT_SYMBOL_GPL(rockchip_system_monitor_register);
EXPORT_SYMBOL(rockchip_system_monitor_register);

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

dev_info(dev, "system monitor probe\n");

return 0;
}

Expand Down

0 comments on commit c43cd9e

Please sign in to comment.