[tiwai-sound:for-next 51/71] sound/core/init.c:1074 snd_component_add() error: we previously assumed 'card->components' could be null (see line 1045)
kernel test robot <[email protected]>
| Newsgroups | dev.linux.lists.oe-kbuild |
|---|---|
| Message-ID | <[email protected]> |
BCC: [email protected] CC: [email protected] CC: [email protected] TO: Maciej Strozek <[email protected]> CC: Takashi Iwai <[email protected]> tree: https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next head: 3690ef20469d5959378260e2752f2314a2572913 commit: 86cac980c9668106b32ffca3bda106cbb6d7ac2b [51/71] ALSA: control: add ioctl to retrieve full card components :::::: branch date: 3 hours ago :::::: commit date: 2 days ago config: arm64-randconfig-r073-20260806 (https://download.01.org/0day-ci/archive/20260807/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 16.1.0 smatch: v0.5.0-9187-g5189e3fb 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 <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/ smatch warnings: sound/core/init.c:1074 snd_component_add() error: we previously assumed 'card->components' could be null (see line 1045) vim +1074 sound/core/init.c e28563cceb9f25 Takashi Iwai 2005-12-01 1025 ^1da177e4c3f41 Linus Torvalds 2005-04-16 1026 /** ^1da177e4c3f41 Linus Torvalds 2005-04-16 1027 * snd_component_add - add a component string ^1da177e4c3f41 Linus Torvalds 2005-04-16 1028 * @card: soundcard structure ^1da177e4c3f41 Linus Torvalds 2005-04-16 1029 * @component: the component id string ^1da177e4c3f41 Linus Torvalds 2005-04-16 1030 * ^1da177e4c3f41 Linus Torvalds 2005-04-16 1031 * This function adds the component id string to the supported list. ^1da177e4c3f41 Linus Torvalds 2005-04-16 1032 * The component can be referred from the alsa-lib. ^1da177e4c3f41 Linus Torvalds 2005-04-16 1033 * eb7c06e8e9c93b Yacine Belkadi 2013-03-11 1034 * Return: Zero otherwise a negative error code. ^1da177e4c3f41 Linus Torvalds 2005-04-16 1035 */ ^1da177e4c3f41 Linus Torvalds 2005-04-16 1036 512bbd6a85230f Takashi Iwai 2005-11-17 1037 int snd_component_add(struct snd_card *card, const char *component) ^1da177e4c3f41 Linus Torvalds 2005-04-16 1038 { ^1da177e4c3f41 Linus Torvalds 2005-04-16 1039 char *ptr; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1040 int len = strlen(component); 86cac980c96681 Maciej Strozek 2026-07-20 1041 unsigned int cur_len, need_len; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1042 86cac980c96681 Maciej Strozek 2026-07-20 1043 guard(rwsem_write)(&snd_ioctl_rwsem); 86cac980c96681 Maciej Strozek 2026-07-20 1044 86cac980c96681 Maciej Strozek 2026-07-20 @1045 if (card->components) { ^1da177e4c3f41 Linus Torvalds 2005-04-16 1046 ptr = strstr(card->components, component); 86cac980c96681 Maciej Strozek 2026-07-20 1047 if (ptr) { ^1da177e4c3f41 Linus Torvalds 2005-04-16 1048 if (ptr[len] == '\0' || ptr[len] == ' ') /* already there */ ^1da177e4c3f41 Linus Torvalds 2005-04-16 1049 return 1; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1050 } 86cac980c96681 Maciej Strozek 2026-07-20 1051 cur_len = strlen(card->components) + 1; 86cac980c96681 Maciej Strozek 2026-07-20 1052 } else { 86cac980c96681 Maciej Strozek 2026-07-20 1053 cur_len = 0; 86cac980c96681 Maciej Strozek 2026-07-20 1054 } 86cac980c96681 Maciej Strozek 2026-07-20 1055 86cac980c96681 Maciej Strozek 2026-07-20 1056 need_len = cur_len + len + 1; 86cac980c96681 Maciej Strozek 2026-07-20 1057 if (need_len > 512) { ^1da177e4c3f41 Linus Torvalds 2005-04-16 1058 snd_BUG(); ^1da177e4c3f41 Linus Torvalds 2005-04-16 1059 return -ENOMEM; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1060 } 86cac980c96681 Maciej Strozek 2026-07-20 1061 86cac980c96681 Maciej Strozek 2026-07-20 1062 if (need_len > card->components_alloc_size) { 86cac980c96681 Maciej Strozek 2026-07-20 1063 unsigned int new_alloc = roundup(need_len, 32); 86cac980c96681 Maciej Strozek 2026-07-20 1064 86cac980c96681 Maciej Strozek 2026-07-20 1065 ptr = krealloc(card->components, new_alloc, GFP_KERNEL); 86cac980c96681 Maciej Strozek 2026-07-20 1066 if (!ptr) 86cac980c96681 Maciej Strozek 2026-07-20 1067 return -ENOMEM; 86cac980c96681 Maciej Strozek 2026-07-20 1068 if (!card->components) 86cac980c96681 Maciej Strozek 2026-07-20 1069 ptr[0] = '\0'; 86cac980c96681 Maciej Strozek 2026-07-20 1070 card->components = ptr; 86cac980c96681 Maciej Strozek 2026-07-20 1071 card->components_alloc_size = new_alloc; 86cac980c96681 Maciej Strozek 2026-07-20 1072 } 86cac980c96681 Maciej Strozek 2026-07-20 1073 ^1da177e4c3f41 Linus Torvalds 2005-04-16 @1074 if (card->components[0] != '\0') ^1da177e4c3f41 Linus Torvalds 2005-04-16 1075 strcat(card->components, " "); ^1da177e4c3f41 Linus Torvalds 2005-04-16 1076 strcat(card->components, component); ^1da177e4c3f41 Linus Torvalds 2005-04-16 1077 return 0; ^1da177e4c3f41 Linus Torvalds 2005-04-16 1078 } c0d3fb39e9511c Takashi Iwai 2006-04-28 1079 EXPORT_SYMBOL(snd_component_add); c0d3fb39e9511c Takashi Iwai 2006-04-28 1080 :::::: The code at line 1074 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2 :::::: TO: Linus Torvalds <[email protected]> :::::: CC: Linus Torvalds <[email protected]> -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki