mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: kernel test robot <lkp@intel.com>
Cc: Kenneth Lee <klee33@uw.edu>,
	oe-kbuild-all@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning: array subscript 'struct kvaser_cmd_ext[0]' is partly outside array bounds of 'unsigned char[32]'
Date: Mon, 31 Oct 2022 09:41:19 +0100	[thread overview]
Message-ID: <20221031084119.bt73s33ps5naz4eh@pengutronix.de> (raw)
In-Reply-To: <202210310759.iwMoLzLT-lkp@intel.com>

[-- Attachment #1: Type: text/plain, Size: 3940 bytes --]

On 31.10.2022 07:35:36, kernel test robot wrote:
> tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head:   30a0b95b1335e12efef89dd78518ed3e4a71a763
> commit: 00784da3e6b8c1f0e58d813272503d014de8f64b can: kvaser_usb: kvaser_usb_hydra: Use kzalloc for allocating only one element
> date:   8 weeks ago
> config: i386-randconfig-r021-20221031
> compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
> reproduce (this is a W=1 build):
>         # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=00784da3e6b8c1f0e58d813272503d014de8f64b
>         git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
>         git fetch --no-tags linus master
>         git checkout 00784da3e6b8c1f0e58d813272503d014de8f64b
>         # save the config file
>         mkdir build_dir && cp config build_dir/.config
>         make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash
> 
> If you fix the issue, kindly add following tag where applicable
> | Reported-by: kernel test robot <lkp@intel.com>
> 
> All warnings (new ones prefixed by >>):
> 
>    In file included from include/linux/byteorder/little_endian.h:5,
>                     from arch/x86/include/uapi/asm/byteorder.h:5,
>                     from include/asm-generic/bitops/le.h:6,
>                     from arch/x86/include/asm/bitops.h:416,
>                     from include/linux/bitops.h:68,
>                     from include/linux/kernel.h:22,
>                     from arch/x86/include/asm/percpu.h:27,
>                     from arch/x86/include/asm/preempt.h:6,
>                     from include/linux/preempt.h:78,
>                     from include/linux/spinlock.h:55,
>                     from include/linux/swait.h:7,
>                     from include/linux/completion.h:12,
>                     from drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:16:
>    drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c: In function 'kvaser_usb_hydra_send_simple_cmd':
> >> drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:65: warning: array subscript 'struct kvaser_cmd_ext[0]' is partly outside array bounds of 'unsigned char[32]' [-Warray-bounds]
>      489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
>    include/uapi/linux/byteorder/little_endian.h:37:51: note: in definition of macro '__le16_to_cpu'
>       37 | #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
>          |                                                   ^
>    drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:489:23: note: in expansion of macro 'le16_to_cpu'
>      489 |                 ret = le16_to_cpu(((struct kvaser_cmd_ext *)cmd)->len);
>          |                       ^~~~~~~~~~~
>    drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c:537:15: note: referencing an object of size 32 allocated by 'kzalloc'
>      537 |         cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
>          |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I think this is a false positive.

The commit you're building 00784da3e6b8 ("can: kvaser_usb:
kvaser_usb_hydra: Use kzalloc for allocating only one element") contains
3e88445a3a5a ("can: kvaser_usb: silence a GCC 12 -Warray-bounds
warning").

In the latter commit, the -Warray-bounds warning was disabled, as gcc-12
has some problem with it. However you're using gcc-11 (Debian 11.3.0-8)
11.3.0 here. Don't know the status of gcc-11 with regards to that
warning.

In the mean time in 26117d92d001 ("can: kvaser_usb: Remove
-Warray-bounds exception") that was removed, as gcc-13 should be fixed.

regards,
Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

      reply	other threads:[~2022-10-31  8:41 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-30 23:35 kernel test robot
2022-10-31  8:41 ` Marc Kleine-Budde [this message]

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=20221031084119.bt73s33ps5naz4eh@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=klee33@uw.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    /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®