From: "Chrisanthus, Anitha" <anitha.chrisanthus@intel.com>
To: Arnd Bergmann <arnd@kernel.org>,
"Dea, Edmund J" <edmund.j.dea@intel.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
"Sam Ravnborg" <sam@ravnborg.org>
Cc: Arnd Bergmann <arnd@arndb.de>, lkp <lkp@intel.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH] drm/kmb: fix array bounds warning
Date: Mon, 30 Nov 2020 22:19:13 +0000 [thread overview]
Message-ID: <BY5PR11MB4182B94E480EFACBF817DFFF8CF50@BY5PR11MB4182.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20201129200927.1854104-1-arnd@kernel.org>
Hi Arnd,
Thanks for your patch.
> -----Original Message-----
> From: Arnd Bergmann <arnd@kernel.org>
> Sent: Sunday, November 29, 2020 12:09 PM
> To: Chrisanthus, Anitha <anitha.chrisanthus@intel.com>; Dea, Edmund J
> <edmund.j.dea@intel.com>; David Airlie <airlied@linux.ie>; Daniel Vetter
> <daniel@ffwll.ch>; Sam Ravnborg <sam@ravnborg.org>
> Cc: Arnd Bergmann <arnd@arndb.de>; lkp <lkp@intel.com>; dri-
> devel@lists.freedesktop.org; linux-kernel@vger.kernel.org
> Subject: [PATCH] drm/kmb: fix array bounds warning
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> gcc warns about an out-of-bounds access when the using nonzero
> values for 'plane_id' on kmb->plane_status:
>
> drivers/gpu/drm/kmb/kmb_plane.c: In function 'kmb_plane_atomic_disable':
> drivers/gpu/drm/kmb/kmb_plane.c:128:20: warning: array subscript 3 is
> above array bounds of 'struct layer_status[1]' [-Warray-bounds]
> 128 | kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL2_ENABLE;
> | ~~~~~~~~~~~~~~~~~^~~~~~~~~~
> drivers/gpu/drm/kmb/kmb_plane.c:125:20: warning: array subscript 2 is
> above array bounds of 'struct layer_status[1]' [-Warray-bounds]
> 125 | kmb->plane_status[plane_id].ctrl = LCD_CTRL_GL1_ENABLE;
> | ~~~~~~~~~~~~~~~~~^~~~~~~~~~
> drivers/gpu/drm/kmb/kmb_plane.c:122:20: warning: array subscript 1 is
> above array bounds of 'struct layer_status[1]' [-Warray-bounds]
> 122 | kmb->plane_status[plane_id].ctrl = LCD_CTRL_VL2_ENABLE;
>
> Having the array truncated to one entry seems intentional, so add
> a range check before indexing it to make it clearer what is going
> on and shut up the warning.
>
> I received the warning from the kernel test robot after a private
> patch that turns on Warray-bounds unconditionally.
>
> Fixes: 7f7b96a8a0a1 ("drm/kmb: Add support for KeemBay Display")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/gpu/drm/kmb/kmb_plane.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/kmb/kmb_plane.c
> b/drivers/gpu/drm/kmb/kmb_plane.c
> index 8448d1edb553..be8eea3830c1 100644
> --- a/drivers/gpu/drm/kmb/kmb_plane.c
> +++ b/drivers/gpu/drm/kmb/kmb_plane.c
> @@ -114,6 +114,9 @@ static void kmb_plane_atomic_disable(struct
> drm_plane *plane,
>
> kmb = to_kmb(plane->dev);
>
> + if (WARN_ON(plane_id >= KMB_MAX_PLANES))
> + return;
> +
Looks good.
Reviewed-by: Anitha Chrisanthus <anitha.chrisanthus@intel.com>
> switch (plane_id) {
> case LAYER_0:
> kmb->plane_status[plane_id].ctrl = LCD_CTRL_VL1_ENABLE;
> --
> 2.27.0
next prev parent reply other threads:[~2020-11-30 22:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-29 20:09 [PATCH] drm/kmb: fix array bounds warning Arnd Bergmann
2020-11-30 22:19 ` Chrisanthus, Anitha [this message]
2020-12-05 19:59 ` Sam Ravnborg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BY5PR11MB4182B94E480EFACBF817DFFF8CF50@BY5PR11MB4182.namprd11.prod.outlook.com \
--to=anitha.chrisanthus@intel.com \
--cc=airlied@linux.ie \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=edmund.j.dea@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=sam@ravnborg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).