summaryrefslogtreecommitdiff
path: root/drivers/video
diff options
context:
space:
mode:
authorRobert Chiras <robert.chiras@nxp.com>2018-12-19 13:11:32 +0200
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:35:46 +0800
commit8069b0648e47275137fafb71c4c8824c94d6e3bc (patch)
tree8a3dfd3360738a39025519be537528aa3d51ab18 /drivers/video
parentc1c1e24f9639372de78549364a7c510b18dd5b10 (diff)
MLK-20295: fbdev/mxsfb: Fix coverity issues
Fixing two coverity issues: 1. Checking disp_videomode against 0, which will always be true, since disp_videomode is a char array. So, fix it by checking it's first byte instead. 2. Possible division by zero, if clk_get_rate returns 0 (which is possible). Signed-off-by: Robert Chiras <robert.chiras@nxp.com>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/fbdev/mxsfb.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c
index 5659ec2d18c4..51740a3f4de5 100644
--- a/drivers/video/fbdev/mxsfb.c
+++ b/drivers/video/fbdev/mxsfb.c
@@ -1248,7 +1248,9 @@ static int mxsfb_restore_mode(struct mxsfb_info *host)
fb_info->var.bits_per_pixel = bits_per_pixel;
- vmode.pixclock = KHZ2PICOS(clk_get_rate(host->clk_pix) / 1000U);
+ vmode.pixclock = clk_get_rate(host->clk_pix) / 1000U;
+ if (vmode.pixclock)
+ vmode.pixclock = KHZ2PICOS(vmode.pixclock);
vmode.hsync_len = get_hsync_pulse_width(host, vdctrl2);
vmode.left_margin = GET_HOR_WAIT_CNT(vdctrl3) - vmode.hsync_len;
vmode.right_margin = VDCTRL2_GET_HSYNC_PERIOD(vdctrl2) - vmode.hsync_len -
@@ -1483,7 +1485,7 @@ static int mxsfb_dispdrv_init(struct platform_device *pdev,
disp_dev[strlen(host->disp_dev)] = '\0';
/* Use videomode name from dtb, if any given */
- if (host->disp_videomode) {
+ if (host->disp_videomode[0]) {
setting.dft_mode_str = kmalloc(NAME_LEN, GFP_KERNEL);
if (setting.dft_mode_str) {
memset(setting.dft_mode_str, 0x0, NAME_LEN);