From 369a5ca92bab9a799f1b5e449300183bc6c80599 Mon Sep 17 00:00:00 2001 From: yxj Date: Wed, 20 Mar 2013 11:26:56 +0800 Subject: [PATCH] rk fb : fix a panic bug panic bug like this: rk_fb_wait_for_vsync_thread may access inf->fb[0] before it is initialized [ 1.009224] Unable to handle kernel NULL pointer dereference at virtual address 00000240 [ 1.017323] pgd = c0404000 [ 1.020035] [00000240] *pgd=00000000 [ 1.023620] Internal error: Oops: 5 [#1] PREEMPT SMP [ 1.028586] CPU: 1 Not tainted (3.0.36+ #217) [ 1.033297] PC is at rk_fb_wait_for_vsync_thread+0xe8/0x144 [ 1.112136] LR is at rk_fb_wait_for_vsync_thread+0xe8/0x144 [ 1.117708] pc : [] lr : [] psr: 60000013 [ 1.117715] sp : efe59f80 ip : c04384a0 fp : 00000000 [ 1.129194] r10: 00000000 r9 : efe59f90 r8 : efe58000 [ 1.134417] r7 : efe39a98 r6 : 00000000 r5 : efe59f84 r4 : efe39a08 [ 1.140942] r3 : 00000000 r2 : 00000000 r1 : efc475a0 r0 : 00000036 [ 1.147469] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel [ 1.154777] Control: 10c5387d Table: 6040404a DAC: 00000015 --- drivers/video/rockchip/rk_fb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/video/rockchip/rk_fb.c b/drivers/video/rockchip/rk_fb.c index 17c1db1c25c4..0297472fce6b 100644 --- a/drivers/video/rockchip/rk_fb.c +++ b/drivers/video/rockchip/rk_fb.c @@ -378,6 +378,7 @@ static int rk_fb_ioctl(struct fb_info *info, unsigned int cmd,unsigned long arg) } #endif #endif + break; default: dev_drv->ioctl(dev_drv,cmd,arg,layer_id); break; @@ -1250,7 +1251,10 @@ int rk_fb_register(struct rk_lcdc_device_driver *dev_drv, ret = -EINVAL; } rkfb_create_sysfs(fbi); - + fb_inf->fb[fb_inf->num_fb] = fbi; + printk("%s>>>>>%s\n",__func__,fb_inf->fb[fb_inf->num_fb]->fix.id); + fb_inf->num_fb++; + if(i == 0) { init_waitqueue_head(&dev_drv->vsync_info.wait); @@ -1270,9 +1274,7 @@ int rk_fb_register(struct rk_lcdc_device_driver *dev_drv, } dev_drv->vsync_info.active = 1; } - fb_inf->fb[fb_inf->num_fb] = fbi; - printk("%s>>>>>%s\n",__func__,fb_inf->fb[fb_inf->num_fb]->fix.id); - fb_inf->num_fb++; + } #if !defined(CONFIG_FRAMEBUFFER_CONSOLE) && defined(CONFIG_LOGO) if(dev_drv->screen_ctr_info->prop == PRMRY) //show logo for primary display device -- 2.34.1