Re: linux-next: build failure after merge of the kspp tree

Kees Cook
2022-01-25T05:16:16Z

On Tue, Jan 25, 2022 at 02:02:21PM +1100, Stephen Rothwell wrote:
> Hi all,
>
> On Tue, 25 Jan 2022 13:55:46 +1100 Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> >
> > After merging the kspp tree, today's linux-next build (powerpc
> > allyesconfig) failed like this:
> >
> > drivers/gpu/drm/kmb/kmb_plane.c: In function 'kmb_plane_atomic_disable':
> > drivers/gpu/drm/kmb/kmb_plane.c:165:34: error: array subscript 3 is above array bounds of 'struct layer_status[2]' [-Werror=array-bounds]
> > 165 | kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL2_ENABLE;
> > | ~~~~~~~~~~~~~~~~~^~~~~~~~~~
> > In file included from drivers/gpu/drm/kmb/kmb_plane.c:17:
> > drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing 'plane_status'
> > 61 | struct layer_status plane_status[KMB_MAX_PLANES];
> > | ^~~~~~~~~~~~
> > drivers/gpu/drm/kmb/kmb_plane.c:162:34: error: array subscript 2 is above array bounds of 'struct layer_status[2]' [-Werror=array-bounds]
> > 162 | kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL1_ENABLE;
> > | ~~~~~~~~~~~~~~~~~^~~~~~~~~~
> > In file included from drivers/gpu/drm/kmb/kmb_plane.c:17:
> > drivers/gpu/drm/kmb/kmb_drv.h:61:41: note: while referencing 'plane_status'
> > 61 | struct layer_status plane_status[KMB_MAX_PLANES];
> > | ^~~~~~~~~~~~
> >
> > Exposed by commit
> >
> > 4ba545781e20 ("Makefile: Enable -Warray-bounds")
> >
> > Originally introduced by commmit
> >
> > 7f7b96a8a0a1 ("drm/kmb: Add support for KeemBay Display")
> >
> > Maybe should have been fixed by
> >
> > c026565fe9be ("drm/kmb: Enable alpha blended second plane")

Yeah, that had fixed it at some point. :(

> >
> > I have applied the following hack for now.
>
> Actually, this one:
>
> From: Stephen Rothwell <sfr@canb.auug.org.au>
> Date: Tue, 25 Jan 2022 13:45:26 +1100
> Subject: [PATCH] hack for building with -Warray-bounds
>
> Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
> ---
> drivers/gpu/drm/kmb/kmb_plane.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/kmb/kmb_plane.c b/drivers/gpu/drm/kmb/kmb_plane.c
> index 00404ba4126d..b54197920712 100644
> --- a/drivers/gpu/drm/kmb/kmb_plane.c
> +++ b/drivers/gpu/drm/kmb/kmb_plane.c
> @@ -158,12 +158,14 @@ static void kmb_plane_atomic_disable(struct drm_plane *plane,
> case LAYER_1:
> kmb->plane_status[plane_id].ctrl = LCD_CTRL_VL2_ENABLE;
> break;
> +#if 0
> case LAYER_2:
> kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL1_ENABLE;
> break;
> case LAYER_3:
> kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL2_ENABLE;
> break;
> +#endif
> }
>
> kmb->plane_status[plane_id].disable = true;

Thanks!

The prior thread about this was here:
https://lore.kernel.org/lkml/20210825181807.1138053-1-keescook@chromium.org/

-Kees

--
Kees Cook