From patchwork Thu Dec 3 01:54:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Wang X-Patchwork-Id: 7755261 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 904A09F1C2 for ; Thu, 3 Dec 2015 02:01:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 92BD12050E for ; Thu, 3 Dec 2015 02:01:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 94481204C9 for ; Thu, 3 Dec 2015 02:01:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757700AbbLCCBh (ORCPT ); Wed, 2 Dec 2015 21:01:37 -0500 Received: from mail-bl2on0132.outbound.protection.outlook.com ([65.55.169.132]:2377 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757633AbbLCCBf (ORCPT ); Wed, 2 Dec 2015 21:01:35 -0500 Received: from CH1PR03CA001.namprd03.prod.outlook.com (10.255.156.146) by CY1PR0301MB1610.namprd03.prod.outlook.com (10.162.166.24) with Microsoft SMTP Server (TLS) id 15.1.331.20; Thu, 3 Dec 2015 02:01:32 +0000 Received: from BL2FFO11FD012.protection.gbl (10.255.156.132) by CH1PR03CA001.outlook.office365.com (10.255.156.146) with Microsoft SMTP Server (TLS) id 15.1.337.19 via Frontend Transport; Thu, 3 Dec 2015 02:01:32 +0000 Authentication-Results: spf=permerror (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; freescale.mail.onmicrosoft.com; dkim=none (message not signed) header.d=none; freescale.mail.onmicrosoft.com; dmarc=none action=none header.from=freescale.com; Received-SPF: PermError (protection.outlook.com: domain of freescale.com used an invalid SPF mechanism) Received: from tx30smr01.am.freescale.net (192.88.168.50) by BL2FFO11FD012.mail.protection.outlook.com (10.173.161.18) with Microsoft SMTP Server (TLS) id 15.1.337.8 via Frontend Transport; Thu, 3 Dec 2015 02:01:31 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id tB321Rnu008048; Wed, 2 Dec 2015 19:01:28 -0700 From: Dongsheng Wang To: CC: , , , Wang Dongsheng Subject: [PATCH v3] video: fbdev: fsl: Fix kernel crash when diu_ops is not implemented Date: Thu, 3 Dec 2015 09:54:12 +0800 Message-ID: <1449107652-5134-1-git-send-email-dongsheng.wang@freescale.com> X-Mailer: git-send-email 2.1.0.27.g96db324 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD012; 1:VKeOwpQ7UH5jFYLBjSKIX94s+k0Xcn3X7lOjZ4xnSy8/pA8Q05U2aWm0DnP4fV25KukIcJf7oBIOHnTaDAe4NAAzRnUlRFL8ATX2umjTDKc7G7bCszT+PJnOPIU90dhPwGASkhric6e1qw24fDea2Cof5CjH1T8L1fIq4Kwoy1jf3N08yRPQOhxHMvKduv3/6GPypdJgs0VVzAFeGfHSQUmgW7JhtSiydXjsUMGnqFDI0QGXv5VHDQ/703XzFZopP6gOFsFYjdxYYxCAiV8FNVByOgD/dXGudhm/fzyIGRCEa/mKyxJSAsRx6wcSO0jkEeeRHe8OuZnN5LuJp5da3t1hNgv0WXT2MPjucYuCCgKB0IGDkHJQOrGXwj+qG6miV3F2vVToVnOdOCO5QABN3qD2GYm+C/oHWiblZCJYn7c= X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(448002)(199003)(189002)(48376002)(92566002)(85326001)(50226001)(586003)(47776003)(86362001)(36756003)(19580405001)(19580395003)(5001960100002)(110136002)(97736004)(107886002)(189998001)(4001430100002)(1220700001)(106466001)(87936001)(77096005)(50466002)(5003940100001)(33646002)(104016004)(11100500001)(2351001)(50986999)(6806005)(229853001)(5008740100001)(1096002)(81156007); DIR:OUT; SFP:1102; SCL:1; SRVR:CY1PR0301MB1610; H:tx30smr01.am.freescale.net; FPR:; SPF:PermError; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1610; 2:Szk9+BShMfvg7YVLwKI7puhUQVT/nChK5PZ7x+HBB2kYJaUKifFjbHo4Of/ABaHYdzrKcLGa5CiOA1zgS+zSac/XLERxA3dQ68asqtpln2Vjul5eAT6amra/LuS5Cz5DRjF27sousdjeSj7zPvea3A==; 3:EYhpIw+IxICtBvpj5GTzLxoH5azFh8Wusept8VWNCKzVPiHcZDneKDm3aeaxKRGn8EjvPcrVce/PDleY0yy6XgHIDh9lP0X7lCl4N0SWmwk8R+8G5Hiyc1jBND/mxQb9mJEpKgTzTI29rJQ3j7XOrDOxKA30xaX7nMVMDbzcq5oaJsSoHWYOrQs3eM6aqspNjWyYX0tN5DrsIPf3k+g7ZScNMYYO4tOcjXftiFlQR74=; 25:q9o5/RArmKBuGdtTVoRdDShXHxZdT3b/skCCVNveR2A7x3VDqRvPhyP6NNuP+gOQYa+iSZCNjI5F+Nw1tWlRpehOnyH4bGg5KYoA1RAYF46u/rlzaZ33qLGR5YPBZVhXCUqDB6VsRQy9VkJ+Uec7OYS4hIeBMl93XnvwHI8nI3s3oBCvx0FvUMClCdqfXc2quYCDAUpdPw+Hft1lXQGzysl7HyjFUYThEOvwfiKJ0x5jB4niieE2qairP9o1qSDZ21v+DvFDFT6/G1Sknr3Bew== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1610; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1610; 20:yC4V/RJOYHYMX00LXwDWBg4x9H0Ng+LYZBhgllTwWpMpVesX6Xl7D+YugyVfRScfxL+9nCjhQxISrA3tuI9PdokjGrZEeF7cJGU6cwDgYP/G7/58+Lzs3wFdDuAd8fr3IEJlD+RJDIhoGRLFg+WxUrxiYMAM3XyYQToaeqztRv194scNfZaHhyBxg2VAw5oV51aUbGjMLd/bZq2yTe1P2zNJSGgTxpEX+yJPekf+BE+2bJGvdbemdGp2ItYpakrTdQLtaJsNojGT96K6Rv6vHbShyLVt0KBByJK81qM8BmBUjhdXH0xhwlp+Uk5CQsI8yqnHS2Erncg5eh8L+J/vr0rICBb9BCneWHxBXg0OVyI=; 4:VdeYIVZmkGxW/vBArsZBjwo4G43TbbbsMItIi/2TzsSjJuHlctFf0cLZKjygNRU8jz4Cv9NVkfp/6Nxw2osxIif7s8EibrxUNQ1uSGANP7zfOq8KIu3Ikr9ZrQXQjUnuQOz2AP4ghOPtr+vBQsXUCmx2uHKwjtX/ExSyuH17OpxkSYmf+rdg0fhIXh8LYlsOVKJBGFMwKebxLAY399MiaJKAR+DVxFNAjGVh1CVpLLoza9MRsQQKlyuJPXMg4S+xo/F7wlN317GaDeLTEo0SguK48aGGzGjWdxu5eYGpbGj2uNW9kocJW1RUYOcMZ4UeN+UIUPVhc9BZ69dfoOHweboe+Pcbn6S3xRP46kQ2ia4bf1MJ9kKq4C0959PRuUv2td1T3jHTHJ2dwpbIaf4TrD3eEKH5Hkm0mACB6IO+hG/+nIZyz4UA9xVtUr/zdaOY X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(101931422205132); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(10201501046); SRVR:CY1PR0301MB1610; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0301MB1610; X-Forefront-PRVS: 077929D941 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1610; 23:gBjQCUxjui4cBJaVn/4N/XVf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vl9iJhxgc7i/stZJIRT6ZzUGfqBzwffq9IWyxnR2?= =?us-ascii?Q?PyHcQkqmRsCMg4pnnZnWYOJsF+lqOEApWTHLU/QyF0UNm45THGslr65at2PS?= =?us-ascii?Q?vD3gwdElPP5uk8QTancmUnTuA?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1610; 5:KXlMTGPCy4MbVQ+j4KC6i9P+MwBipKIT5iGrMPTbhKQIp84EtdFME0wiazJJfuuI9ms4DNgB2t75MZhGBPGueYy0AMKZX5GMy2p7+RvoHzJbDbL5Wnnthq3V417GDr/qG8K2h67yVW8fNxjMgnoO6A==; 24:dv/yGGlzHOu3/vrUcRhEY6YPOfB851y76PHOe0FYA42qRKhSKzYKhi2zB7o4ezWRtZH5WrVpwYZ4sdZqnhnJm33pjuSLSR29XI8aL5EEK8A= X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Dec 2015 02:01:31.5474 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1610 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wang Dongsheng 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 Acked-by: Timur Tabi --- 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(-) 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