Re: [PATCH 5/5] ARM: OMAP2+: clean up some cppcheck warnings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 13 Mar 2012, Jarkko Nikula wrote:

> On 03/13/2012 12:43 AM, Paul Walmsley wrote:
> > Resolve some warnings identified by cppcheck in arch/arm/mach-omap2:
> ...
> >     [arch/arm/mach-omap2/mcbsp.c:133]: (warning) scanf without field width limits can crash with huge input data
> ...
> > diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c
> > index fb4bcf8..efe59c7 100644
> 
> > --- a/arch/arm/mach-omap2/mcbsp.c
> > +++ b/arch/arm/mach-omap2/mcbsp.c
> > @@ -130,7 +130,7 @@ static int omap_init_mcbsp(struct omap_hwmod *oh, void *unused)
> >  	struct omap_mcbsp_platform_data *pdata = NULL;
> >  	struct platform_device *pdev;
> >  
> > -	sscanf(oh->name, "mcbsp%d", &id);
> > +	sscanf(oh->name, "mcbsp%1d", &id);
> >  
> Correct if I'm wrong but is this a false alarm? Can %d scan more than
> sizeof(int)?
> 
> Anyway this shouldn't be fatal issue since name comes from kernel
> omap_hwmod data, i.e. only developer can hit it.

Yes, I wasn't too worried about this one.  At the time, I didn't audit the 
kernel sscanf(), so I wasn't sure what its behavior was here. Glancing at 
that code now, it seems to ignore the field width for %d anyway.  So this 
is probably a pointless change that can be dropped from the patch.

Thanks for the review.


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


[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux