From patchwork Thu Jun 11 13:13:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiko Schocher X-Patchwork-Id: 6588451 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 8C8F1C0020 for ; Thu, 11 Jun 2015 13:13:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88D712037F for ; Thu, 11 Jun 2015 13:13:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4CBF22022D for ; Thu, 11 Jun 2015 13:13:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752831AbbFKNNX (ORCPT ); Thu, 11 Jun 2015 09:13:23 -0400 Received: from mail-out.m-online.net ([212.18.0.9]:37735 "EHLO mail-out.m-online.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752445AbbFKNNU (ORCPT ); Thu, 11 Jun 2015 09:13:20 -0400 Received: from frontend02.mail.m-online.net (unknown [192.168.8.183]) by mail-out.m-online.net (Postfix) with ESMTP id 3m6lx92t1Wz3hjSQ; Thu, 11 Jun 2015 15:13:17 +0200 (CEST) Received: from localhost (dynscan2.mnet-online.de [192.168.6.69]) by mail.m-online.net (Postfix) with ESMTP id 3m6lx90pMSzvhP8; Thu, 11 Jun 2015 15:13:17 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.184]) by localhost (dynscan2.mail.m-online.net [192.168.6.69]) (amavisd-new, port 10024) with ESMTP id Xm6_TD0Zs4Na; Thu, 11 Jun 2015 15:13:15 +0200 (CEST) X-Auth-Info: dqsdXF5FyrDN4U/WSVLyv8QGMIBGxb/7NzlCjOihbk8= Received: from mail-internal.denx.de (host-82-135-33-74.customer.m-online.net [82.135.33.74]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA; Thu, 11 Jun 2015 15:13:15 +0200 (CEST) Received: from pollux.denx.de (pollux [192.168.1.1]) by mail-internal.denx.de (Postfix) with ESMTP id A0BCC343309; Thu, 11 Jun 2015 15:13:15 +0200 (CEST) Received: by pollux.denx.de (Postfix, from userid 515) id 6162EFE8; Thu, 11 Jun 2015 15:13:15 +0200 (CEST) From: Heiko Schocher To: linux-fbdev@vger.kernel.org Cc: Heiko Schocher , devicetree@vger.kernel.org, Rasmus Villemoes , linux-kernel@vger.kernel.org, Tomi Valkeinen , Grant Likely , Rob Herring , Jean-Christophe Plagniol-Villard , Andrew Morton Subject: [PATCH] video: sm501fb: fixing static checker warning Date: Thu, 11 Jun 2015 15:13:13 +0200 Message-Id: <1434028393-32224-1-git-send-email-hs@denx.de> X-Mailer: git-send-email 2.1.0 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 Dan Carpenter reported the static checker warning: drivers/video/fbdev/sm501fb.c:1958 sm501fb_probe() warn: strcpy() 'cp' of unknown size might be too large for 'fb_mode' Fix it, as the SM501 datasheet says the SM501 can "200 MHz DAC support 1280x1024 resolution", which would result in a too long mode string for current fb_mode var. Reported-by: Dan Carpenter Signed-off-by: Heiko Schocher --- drivers/video/fbdev/sm501fb.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/sm501fb.c b/drivers/video/fbdev/sm501fb.c index 9e74e8f..ea50df3 100644 --- a/drivers/video/fbdev/sm501fb.c +++ b/drivers/video/fbdev/sm501fb.c @@ -43,7 +43,9 @@ #include "edid.h" -static char *fb_mode = "640x480-16@60"; +static char *fb_default_mode = "640x480-16@60"; +static char fb_mode[20]; +static char *fb_mode_cmdline; static unsigned long default_bpp = 16; static struct fb_videomode sm501_default_mode = { @@ -1963,6 +1965,12 @@ static int sm501fb_probe(struct platform_device *pdev) if (info->edid_data) found = 1; } + } else { + if (fb_mode_cmdline) + strncpy(fb_mode, fb_mode_cmdline, + sizeof(fb_mode) - 1); + else + strcpy(fb_mode, fb_default_mode); } #endif if (!found) { @@ -2230,7 +2238,7 @@ static struct platform_driver sm501fb_driver = { module_platform_driver(sm501fb_driver); -module_param_named(mode, fb_mode, charp, 0); +module_param_named(mode, fb_mode_cmdline, charp, 0); MODULE_PARM_DESC(mode, "Specify resolution as \"x[-][@]\" "); module_param_named(bpp, default_bpp, ulong, 0);