sound/core/ump.c:676:25: warning: array subscript 'struct snd_ump_block_info[0]' is partly outside array bounds of 'char[20]'

From: kernel test robot
Date: Tue Sep 19 2023 - 07:07:56 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 2cf0f715623872823a72e451243bbf555d10d032
commit: 4a16a3af05712e7fd5a205f34e2908055bd9fb5e ALSA: seq: ump: Handle FB info update
date: 3 months ago
config: x86_64-randconfig-004-20230919 (https://download.01.org/0day-ci/archive/20230919/202309191806.9xysweCr-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230919/202309191806.9xysweCr-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309191806.9xysweCr-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

In function 'fill_fb_info',
inlined from 'is_fb_info_updated.constprop' at sound/core/ump.c:699:2:
>> sound/core/ump.c:676:25: warning: array subscript 'struct snd_ump_block_info[0]' is partly outside array bounds of 'char[20]' [-Warray-bounds]
676 | info->direction = buf->fb_info.direction;
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sound/core/ump.c: In function 'is_fb_info_updated.constprop':
sound/core/ump.c:696:14: note: object 'tmpbuf' of size 20
696 | char tmpbuf[offsetof(struct snd_ump_block_info, name)];
| ^~~~~~
In function 'fill_fb_info',
inlined from 'is_fb_info_updated.constprop' at sound/core/ump.c:699:2:
sound/core/ump.c:677:23: warning: array subscript 'struct snd_ump_block_info[0]' is partly outside array bounds of 'char[20]' [-Warray-bounds]
677 | info->ui_hint = buf->fb_info.ui_hint;
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
sound/core/ump.c: In function 'is_fb_info_updated.constprop':
sound/core/ump.c:696:14: note: object 'tmpbuf' of size 20
696 | char tmpbuf[offsetof(struct snd_ump_block_info, name)];
| ^~~~~~
In function 'fill_fb_info',
inlined from 'is_fb_info_updated.constprop' at sound/core/ump.c:699:2:
sound/core/ump.c:678:27: warning: array subscript 'struct snd_ump_block_info[0]' is partly outside array bounds of 'char[20]' [-Warray-bounds]
678 | info->first_group = buf->fb_info.first_group;
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
sound/core/ump.c: In function 'is_fb_info_updated.constprop':
sound/core/ump.c:696:14: note: object 'tmpbuf' of size 20
696 | char tmpbuf[offsetof(struct snd_ump_block_info, name)];
| ^~~~~~
In function 'fill_fb_info',
inlined from 'is_fb_info_updated.constprop' at sound/core/ump.c:699:2:
sound/core/ump.c:679:26: warning: array subscript 'struct snd_ump_block_info[0]' is partly outside array bounds of 'char[20]' [-Warray-bounds]
679 | info->num_groups = buf->fb_info.num_groups;
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sound/core/ump.c: In function 'is_fb_info_updated.constprop':
sound/core/ump.c:696:14: note: object 'tmpbuf' of size 20
696 | char tmpbuf[offsetof(struct snd_ump_block_info, name)];
| ^~~~~~
In function 'fill_fb_info',
inlined from 'is_fb_info_updated.constprop' at sound/core/ump.c:699:2:
sound/core/ump.c:680:21: warning: array subscript 'struct snd_ump_block_info[0]' is partly outside array bounds of 'char[20]' [-Warray-bounds]
680 | info->flags = buf->fb_info.midi_10;
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
sound/core/ump.c: In function 'is_fb_info_updated.constprop':
sound/core/ump.c:696:14: note: object 'tmpbuf' of size 20
696 | char tmpbuf[offsetof(struct snd_ump_block_info, name)];
| ^~~~~~
In function 'fill_fb_info',
inlined from 'is_fb_info_updated.constprop' at sound/core/ump.c:699:2:
sound/core/ump.c:681:22: warning: array subscript 'struct snd_ump_block_info[0]' is partly outside array bounds of 'char[20]' [-Warray-bounds]
681 | info->active = buf->fb_info.active;
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
sound/core/ump.c: In function 'is_fb_info_updated.constprop':
sound/core/ump.c:696:14: note: object 'tmpbuf' of size 20
696 | char tmpbuf[offsetof(struct snd_ump_block_info, name)];
| ^~~~~~
In function 'fill_fb_info',
inlined from 'is_fb_info_updated.constprop' at sound/core/ump.c:699:2:
sound/core/ump.c:682:31: warning: array subscript 'struct snd_ump_block_info[0]' is partly outside array bounds of 'char[20]' [-Warray-bounds]
682 | info->midi_ci_version = buf->fb_info.midi_ci_version;
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/core/ump.c: In function 'is_fb_info_updated.constprop':
sound/core/ump.c:696:14: note: object 'tmpbuf' of size 20
696 | char tmpbuf[offsetof(struct snd_ump_block_info, name)];
| ^~~~~~
In function 'fill_fb_info',
inlined from 'is_fb_info_updated.constprop' at sound/core/ump.c:699:2:
sound/core/ump.c:683:30: warning: array subscript 'struct snd_ump_block_info[0]' is partly outside array bounds of 'char[20]' [-Warray-bounds]
683 | info->sysex8_streams = buf->fb_info.sysex8_streams;
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
sound/core/ump.c: In function 'is_fb_info_updated.constprop':
sound/core/ump.c:696:14: note: object 'tmpbuf' of size 20
696 | char tmpbuf[offsetof(struct snd_ump_block_info, name)];
| ^~~~~~


vim +676 sound/core/ump.c

37e0e14128e068 Takashi Iwai 2023-06-12 670
37e0e14128e068 Takashi Iwai 2023-06-12 671 /* Extract Function Block info from UMP packet */
37e0e14128e068 Takashi Iwai 2023-06-12 672 static void fill_fb_info(struct snd_ump_endpoint *ump,
37e0e14128e068 Takashi Iwai 2023-06-12 673 struct snd_ump_block_info *info,
37e0e14128e068 Takashi Iwai 2023-06-12 674 const union snd_ump_stream_msg *buf)
37e0e14128e068 Takashi Iwai 2023-06-12 675 {
37e0e14128e068 Takashi Iwai 2023-06-12 @676 info->direction = buf->fb_info.direction;
37e0e14128e068 Takashi Iwai 2023-06-12 677 info->ui_hint = buf->fb_info.ui_hint;
37e0e14128e068 Takashi Iwai 2023-06-12 678 info->first_group = buf->fb_info.first_group;
37e0e14128e068 Takashi Iwai 2023-06-12 679 info->num_groups = buf->fb_info.num_groups;
37e0e14128e068 Takashi Iwai 2023-06-12 680 info->flags = buf->fb_info.midi_10;
37e0e14128e068 Takashi Iwai 2023-06-12 681 info->active = buf->fb_info.active;
37e0e14128e068 Takashi Iwai 2023-06-12 682 info->midi_ci_version = buf->fb_info.midi_ci_version;
37e0e14128e068 Takashi Iwai 2023-06-12 683 info->sysex8_streams = buf->fb_info.sysex8_streams;
37e0e14128e068 Takashi Iwai 2023-06-12 684
37e0e14128e068 Takashi Iwai 2023-06-12 685 ump_dbg(ump, "FB %d: dir=%d, active=%d, first_gp=%d, num_gp=%d, midici=%d, sysex8=%d, flags=0x%x\n",
37e0e14128e068 Takashi Iwai 2023-06-12 686 info->block_id, info->direction, info->active,
37e0e14128e068 Takashi Iwai 2023-06-12 687 info->first_group, info->num_groups, info->midi_ci_version,
37e0e14128e068 Takashi Iwai 2023-06-12 688 info->sysex8_streams, info->flags);
37e0e14128e068 Takashi Iwai 2023-06-12 689 }
37e0e14128e068 Takashi Iwai 2023-06-12 690

:::::: The code at line 676 was first introduced by commit
:::::: 37e0e14128e0685267dc5c037bf655421a6ce2ea ALSA: ump: Support UMP Endpoint and Function Block parsing

:::::: TO: Takashi Iwai <tiwai@xxxxxxx>
:::::: CC: Takashi Iwai <tiwai@xxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki