From 4352109eb418e7f9520df93a6d19923095ea8d30 Mon Sep 17 00:00:00 2001 From: Fancy Fang Date: Tue, 25 Aug 2015 16:13:55 +0800 Subject: [PATCH] MLK-11395-5 video: mxsfb: add modelist empty check before using it Signed-off-by: Fancy Fang --- drivers/video/fbdev/mxsfb.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c index 9edec5465c7e..e7ac2574d907 100644 --- a/drivers/video/fbdev/mxsfb.c +++ b/drivers/video/fbdev/mxsfb.c @@ -1232,10 +1232,12 @@ static int mxsfb_init_fbinfo(struct mxsfb_info *host) else sprintf(fb_info->fix.id, "mxs-lcdif%d", host->id); - /* first video mode in the modelist as default video mode */ - modelist = list_first_entry(&fb_info->modelist, - struct fb_modelist, list); - fb_videomode_to_var(var, &modelist->mode); + if (!list_empty(&fb_info->modelist)) { + /* first video mode in the modelist as default video mode */ + modelist = list_first_entry(&fb_info->modelist, + struct fb_modelist, list); + fb_videomode_to_var(var, &modelist->mode); + } /* save the sync value getting from dtb */ host->sync = fb_info->var.sync; -- 2.17.1