Re: drivers/leds/trigger/ledtrig-netdev.c:120:34: warning: array subscript 17 is above array bounds of 'char[16]'

From: Liu, Yujie
Date: Sat Oct 07 2023 - 20:36:45 EST


On Sat, 2023-10-07 at 15:15 +0200, Christian Marangi wrote:
> > > > >
> > > > > Can't repro so I guess this was a false-positive that got
> > > > > fixed?
> > > > > (I used
> > > > > the repro commands and doesn't print any error)
> > > >
> > > > Hi Ansuel, the issue requires to build with -Warray-bounds
> > > > flag. We
> > > > will fix
> > > > the reproduce steps in earliest time. Sorry for the
> > > > inconvenience.
> > > >
> > >
> > > Hi again, happy to help you further.
> > >
> > > By adding the flag I still can't repro.
> > > I'm using this command.
> > > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-13.2.0
> > > ~/bin/make.cross
> > > W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash
> > > drivers/leds/trigger/ 
> > > -Warray-bounds
> >
> > Hi Ansuel, we added some extra compiler flags recently but the
> > repro
> > steps were not updated in time. Sorry for this.
> >
> > Could you please have a try with the following command? (append
> > KCFLAGS="-Warray-bounds" at the end)
> >
> > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-13.2.0
> > ~/bin/make.cross W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash
> > drivers/leds/trigger/ KCFLAGS="-Warray-bounds"
> >
>
> Can confirm this worked! (also sent patch upstream)
>
> May I suggest some improvement to the repro script?
>
> I would add some instruction on the cleanup... A simple rm -rf with all
> the toolchain and directory downloaded may be useful.
>
> Also some reference on the config to download to exactly repro the
> error? If someone doesn't download the config from the mail, the default
> kernel config for the ARCH is used and the bug is not repro.
>
> I know these are all steps that a kernel dev should already know but
> since we are giving instructions, it might not be a bad idea to include
> every required step.

Thanks a lot for the suggestion. We will soon be refining the repro
instructions to be more accurate.

Best Regards,
Yujie