From 3dd5febeecd16e8288fde355ced4526c7baf11bd Mon Sep 17 00:00:00 2001 From: Nirmal Abraham Date: Thu, 1 Aug 2019 10:34:40 +0530 Subject: fbdev: msm: Call vsync_handler only after ctl start In hdmi-as-primary usecase with resolution change, the vsync_handler can get called from overlay_on function before the vsync handler is registered via ctl_start. Add a check to avoid the null ptr access while accessing the vsync handler function ptr in this case. Change-Id: Ic47b10502939c4a4751c78da1f8fe28b3005cf3b Signed-off-by: Nirmal Abraham --- drivers/video/fbdev/msm/mdss_mdp_overlay.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/video/fbdev/msm/mdss_mdp_overlay.c b/drivers/video/fbdev/msm/mdss_mdp_overlay.c index 324e5e9ca60d..daeed5d45072 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_overlay.c +++ b/drivers/video/fbdev/msm/mdss_mdp_overlay.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -5762,12 +5762,14 @@ static int mdss_mdp_overlay_on(struct msm_fb_data_type *mfd) panel_on: if (mdp5_data->vsync_en) { - pr_info("reenabling vsync for fb%d\n", mfd->index); - mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_ON); - rc = ctl->ops.add_vsync_handler(ctl, &ctl->vsync_handler); - mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_OFF); + if ((ctl) && (ctl->ops.add_vsync_handler)) { + pr_info("reenabling vsync for fb%d\n", mfd->index); + mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_ON); + rc = ctl->ops.add_vsync_handler(ctl, + &ctl->vsync_handler); + mdss_mdp_clk_ctrl(MDP_BLOCK_POWER_OFF); + } } - if (IS_ERR_VALUE(rc)) { pr_err("Failed to turn on fb%d\n", mfd->index); mdss_mdp_overlay_off(mfd); -- cgit v1.2.3