From: Donald Robson <Donald.Robson@imgtec.com>
To: Frank Binns <Frank.Binns@imgtec.com>,
Matt Coster <Matt.Coster@imgtec.com>,
"arnd@kernel.org" <arnd@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"tzimmermann@suse.de" <tzimmermann@suse.de>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"airlied@gmail.com" <airlied@gmail.com>,
"arnd@arndb.de" <arnd@arndb.de>,
Sarah Walker <Sarah.Walker@imgtec.com>,
"maarten.lankhorst@linux.intel.com"
<maarten.lankhorst@linux.intel.com>,
"daniel@ffwll.ch" <daniel@ffwll.ch>,
"mripard@kernel.org" <mripard@kernel.org>
Subject: Re: [PATCH 2/2] drm/imagination: avoid -Woverflow warning
Date: Wed, 29 Nov 2023 12:01:20 +0000 [thread overview]
Message-ID: <9df9e4f87727399928c068dbbf614c9895ae15f9.camel@imgtec.com> (raw)
In-Reply-To: <20231129113825.2961913-2-arnd@kernel.org>
Hello Arnd,
Thanks for the patch. I'm slightly concerned that we've not seen this warning when
building here. I guess we need to check our CI settings...
Reviewed-by: Donald Robson <donald.robson@imgtec.com>
On Wed, 2023-11-29 at 12:33 +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> The array size calculation in pvr_vm_mips_fini() appears to be incorrect based on
> taking the size of the pointer rather than the size of the array, which manifests
> as a warning about signed integer overflow:
>
> In file included from include/linux/kernel.h:16,
> from drivers/gpu/drm/imagination/pvr_rogue_fwif.h:10,
> from drivers/gpu/drm/imagination/pvr_ccb.h:7,
> from drivers/gpu/drm/imagination/pvr_device.h:7,
> from drivers/gpu/drm/imagination/pvr_vm_mips.c:4:
> drivers/gpu/drm/imagination/pvr_vm_mips.c: In function 'pvr_vm_mips_fini':
> include/linux/array_size.h:11:25: error: overflow in conversion from 'long unsigned int' to 'int' changes value from '18446744073709551615' to '-1' [-Werror=overflow]
> 11 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
> | ^
> drivers/gpu/drm/imagination/pvr_vm_mips.c:106:24: note: in expansion of macro 'ARRAY_SIZE'
> 106 | for (page_nr = ARRAY_SIZE(mips_data->pt_pages) - 1; page_nr >= 0; page_nr--) {
> | ^~~~~~~~~~
>
> Just use the number of array elements directly here, and in the corresponding
> init function for consistency.
>
> Fixes: 927f3e0253c1 ("drm/imagination: Implement MIPS firmware processor and MMU support")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/gpu/drm/imagination/pvr_vm_mips.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/imagination/pvr_vm_mips.c b/drivers/gpu/drm/imagination/pvr_vm_mips.c
> index 7268cf6e630b..6c2e4cc4e6db 100644
> --- a/drivers/gpu/drm/imagination/pvr_vm_mips.c
> +++ b/drivers/gpu/drm/imagination/pvr_vm_mips.c
> @@ -46,7 +46,7 @@ pvr_vm_mips_init(struct pvr_device *pvr_dev)
> if (!mips_data)
> return -ENOMEM;
>
> - for (page_nr = 0; page_nr < ARRAY_SIZE(mips_data->pt_pages); page_nr++) {
> + for (page_nr = 0; page_nr < PVR_MIPS_PT_PAGE_COUNT; page_nr++) {
> mips_data->pt_pages[page_nr] = alloc_page(GFP_KERNEL | __GFP_ZERO);
> if (!mips_data->pt_pages[page_nr]) {
> err = -ENOMEM;
> @@ -103,7 +103,7 @@ pvr_vm_mips_fini(struct pvr_device *pvr_dev)
> int page_nr;
>
> vunmap(mips_data->pt);
> - for (page_nr = ARRAY_SIZE(mips_data->pt_pages) - 1; page_nr >= 0; page_nr--) {
> + for (page_nr = PVR_MIPS_PT_PAGE_COUNT - 1; page_nr >= 0; page_nr--) {
> dma_unmap_page(from_pvr_device(pvr_dev)->dev,
> mips_data->pt_dma_addr[page_nr], PAGE_SIZE, DMA_TO_DEVICE);
>
next prev parent reply other threads:[~2023-11-29 12:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-29 11:33 [PATCH 1/2] drm/imagination: avoid -Wmissing-prototype warnings Arnd Bergmann
2023-11-29 11:33 ` [PATCH 2/2] drm/imagination: avoid -Woverflow warning Arnd Bergmann
2023-11-29 12:01 ` Donald Robson [this message]
2023-11-29 12:04 ` Arnd Bergmann
2023-11-29 12:15 ` [EXTERNAL] " Donald Robson
2023-11-29 12:07 ` [PATCH 1/2] drm/imagination: avoid -Wmissing-prototype warnings Donald Robson
2023-11-29 12:16 ` Arnd Bergmann
2023-11-29 12:21 ` [EXTERNAL] " Donald Robson
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=9df9e4f87727399928c068dbbf614c9895ae15f9.camel@imgtec.com \
--to=donald.robson@imgtec.com \
--cc=Frank.Binns@imgtec.com \
--cc=Matt.Coster@imgtec.com \
--cc=Sarah.Walker@imgtec.com \
--cc=airlied@gmail.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®