diff mbox

[v3] video: fbdev: fsl: Fix kernel crash when diu_ops is not implemented

Message ID 1449107652-5134-1-git-send-email-dongsheng.wang@freescale.com (mailing list archive)
State New, archived
Headers show

Commit Message

Dongsheng Wang Dec. 3, 2015, 1:54 a.m. UTC
From: Wang Dongsheng <dongsheng.wang@freescale.com>

If diu_ops is not implemented on platform, kernel will access a NULL
pointer. We need to check this pointer in DIU initialization.

Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
---
v3:
- Fix capitalization in patch description.
- Add comments for verify diu_ops.set_pixel_clock.

v2:
- Move set_pixel_clock judgement to fsl_diu_init.

 drivers/video/fbdev/fsl-diu-fb.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

Comments

Timur Tabi Dec. 3, 2015, 2:03 p.m. UTC | #1
Dongsheng Wang wrote:
> From: Wang Dongsheng<dongsheng.wang@freescale.com>
>
> If diu_ops is not implemented on platform, kernel will access a NULL
> pointer. We need to check this pointer in DIU initialization.
>
> Signed-off-by: Wang Dongsheng<dongsheng.wang@freescale.com>

Acked-by: Timur Tabi <timur@tabi.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tomi Valkeinen Dec. 7, 2015, 4:57 p.m. UTC | #2
On 03/12/15 03:54, Dongsheng Wang wrote:
> From: Wang Dongsheng <dongsheng.wang@freescale.com>
> 
> If diu_ops is not implemented on platform, kernel will access a NULL
> pointer. We need to check this pointer in DIU initialization.
> 
> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
> ---
> v3:
> - Fix capitalization in patch description.
> - Add comments for verify diu_ops.set_pixel_clock.
> 
> v2:
> - Move set_pixel_clock judgement to fsl_diu_init.
> 
>  drivers/video/fbdev/fsl-diu-fb.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)

Thanks, queued for 4.4 fixes.

 Tomi
Scott Wood Dec. 7, 2015, 5:07 p.m. UTC | #3
On Thu, 2015-12-03 at 09:54 +0800, Dongsheng Wang wrote:
> From: Wang Dongsheng <dongsheng.wang@freescale.com>
> 
> If diu_ops is not implemented on platform, kernel will access a NULL
> pointer. We need to check this pointer in DIU initialization.
> 
> Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com>
> ---
> v3:
> - Fix capitalization in patch description.
> - Add comments for verify diu_ops.set_pixel_clock.
> 
> v2:
> - Move set_pixel_clock judgement to fsl_diu_init.
> 
>  drivers/video/fbdev/fsl-diu-fb.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)

Why did you not CC stable as I previously requested?

-Scott

--
To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/video/fbdev/fsl-diu-fb.c b/drivers/video/fbdev/fsl-diu-fb.c
index b335c1a..4a7797a 100644
--- a/drivers/video/fbdev/fsl-diu-fb.c
+++ b/drivers/video/fbdev/fsl-diu-fb.c
@@ -479,7 +479,10 @@  static enum fsl_diu_monitor_port fsl_diu_name_to_port(const char *s)
 			port = FSL_DIU_PORT_DLVDS;
 	}
 
-	return diu_ops.valid_monitor_port(port);
+	if (diu_ops.valid_monitor_port)
+		port = diu_ops.valid_monitor_port(port);
+
+	return port;
 }
 
 /*
@@ -1915,6 +1918,14 @@  static int __init fsl_diu_init(void)
 #else
 	monitor_port = fsl_diu_name_to_port(monitor_string);
 #endif
+
+	/*
+	 * Must to verify set_pixel_clock. If not implement on platform,
+	 * then that means that there is no platform support for the DIU.
+	 */
+	if (!diu_ops.set_pixel_clock)
+		return -ENODEV;
+
 	pr_info("Freescale Display Interface Unit (DIU) framebuffer driver\n");
 
 #ifdef CONFIG_NOT_COHERENT_CACHE