* [PATCH] video: sm501fb: fixing static checker warning
@ 2015-06-11 13:13 Heiko Schocher
2015-06-12 9:34 ` Tomi Valkeinen
0 siblings, 1 reply; 2+ messages in thread
From: Heiko Schocher @ 2015-06-11 13:13 UTC (permalink / raw)
To: linux-fbdev-u79uwXL29TY76Z2rM5mHXA
Cc: Heiko Schocher, devicetree-u79uwXL29TY76Z2rM5mHXA,
Rasmus Villemoes, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
Tomi Valkeinen, Grant Likely, Rob Herring,
Jean-Christophe Plagniol-Villard, Andrew Morton
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 <dan.carpenter@oracle.com>
Signed-off-by: Heiko Schocher <hs@denx.de>
---
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 \"<xres>x<yres>[-<bpp>][@<refresh>]\" ");
module_param_named(bpp, default_bpp, ulong, 0);
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] video: sm501fb: fixing static checker warning
2015-06-11 13:13 [PATCH] video: sm501fb: fixing static checker warning Heiko Schocher
@ 2015-06-12 9:34 ` Tomi Valkeinen
0 siblings, 0 replies; 2+ messages in thread
From: Tomi Valkeinen @ 2015-06-12 9:34 UTC (permalink / raw)
To: Heiko Schocher, linux-fbdev
Cc: devicetree, Rasmus Villemoes, linux-kernel, Grant Likely,
Rob Herring, Jean-Christophe Plagniol-Villard, Andrew Morton
[-- Attachment #1: Type: text/plain, Size: 1737 bytes --]
On 11/06/15 16:13, Heiko Schocher wrote:
> 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 <dan.carpenter@oracle.com>
> Signed-off-by: Heiko Schocher <hs@denx.de>
> ---
>
> 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
I didn't look at this very closely, but it doesn't look correct to me.
The above code will only be ran if !np. Shouldn't the kernel cmdline
parameter override anything from the .dts?
Then again, that's how it works at the moment, so I guess this is ok.
Tomi
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-06-12 9:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-11 13:13 [PATCH] video: sm501fb: fixing static checker warning Heiko Schocher
2015-06-12 9:34 ` Tomi Valkeinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).