From 0e6a39bfec201f5bad0b762c232daefc69bb248a Mon Sep 17 00:00:00 2001 From: zwl Date: Fri, 4 Jul 2014 09:29:04 +0800 Subject: [PATCH] rk screen: add the judgement if the variable rk_screen is null pointer --- drivers/video/rockchip/screen/rk_screen.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/video/rockchip/screen/rk_screen.c b/drivers/video/rockchip/screen/rk_screen.c index 242ba4fb668a..0c031275d414 100755 --- a/drivers/video/rockchip/screen/rk_screen.c +++ b/drivers/video/rockchip/screen/rk_screen.c @@ -7,12 +7,18 @@ static struct rk_screen *rk_screen; int rk_fb_get_prmry_screen(struct rk_screen *screen) { + if (unlikely(!rk_screen) || unlikely(!screen)) + return -1; + memcpy(screen, rk_screen, sizeof(struct rk_screen)); return 0; } int rk_fb_set_prmry_screen(struct rk_screen *screen) { + if (unlikely(!rk_screen) || unlikely(!screen)) + return -1; + rk_screen->lcdc_id = screen->lcdc_id; rk_screen->screen_id = screen->screen_id; rk_screen->x_mirror = screen->x_mirror; @@ -27,16 +33,22 @@ int rk_fb_set_prmry_screen(struct rk_screen *screen) size_t get_fb_size(void) { size_t size = 0; - int xres = rk_screen->mode.xres; - int yres = rk_screen->mode.yres; + u32 xres = 0; + u32 yres = 0; + + if (unlikely(!rk_screen)) + return 0; + + xres = rk_screen->mode.xres; + yres = rk_screen->mode.yres; - /*align as 64 bytes(16*4) in an odd number of times*/ + /* align as 64 bytes(16*4) in an odd number of times */ xres = ALIGN_64BYTE_ODD_TIMES(xres, ALIGN_PIXEL_64BYTE_RGB8888); #if defined(CONFIG_THREE_FB_BUFFER) - size = (xres * yres << 2) * 3; //three buffer + size = (xres * yres << 2) * 3; /* three buffer */ #else - size = (xres * yres << 2) << 1; //two buffer + size = (xres * yres << 2) << 1; /* two buffer */ #endif return ALIGN(size, SZ_1M); } -- 2.34.1