Messages in this thread | | | Date | Sat, 19 Jun 2021 16:46:13 +0300 | From | Dan Carpenter <> | Subject | fs/cifs/cifs_swn.c:468 cifs_swn_store_swn_addr() error: uninitialized symbol 'port'. |
| |
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 9ed13a17e38e0537e24d9b507645002bf8d0201f commit: 121d947d4fe15bcec90bcfc1249ee9b739cb9258 cifs: Handle witness client move notification config: h8300-randconfig-m031-20210618 (attached as .config) compiler: h8300-linux-gcc (GCC) 9.3.0
If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings: fs/cifs/cifs_swn.c:468 cifs_swn_store_swn_addr() error: uninitialized symbol 'port'.
vim +/port +468 fs/cifs/cifs_swn.c
121d947d4fe15b Samuel Cabrero 2020-11-30 447 static int cifs_swn_store_swn_addr(const struct sockaddr_storage *new, 121d947d4fe15b Samuel Cabrero 2020-11-30 448 const struct sockaddr_storage *old, 121d947d4fe15b Samuel Cabrero 2020-11-30 449 struct sockaddr_storage *dst) 121d947d4fe15b Samuel Cabrero 2020-11-30 450 { 121d947d4fe15b Samuel Cabrero 2020-11-30 451 __be16 port; 121d947d4fe15b Samuel Cabrero 2020-11-30 452 121d947d4fe15b Samuel Cabrero 2020-11-30 453 if (old->ss_family == AF_INET) { 121d947d4fe15b Samuel Cabrero 2020-11-30 454 struct sockaddr_in *ipv4 = (struct sockaddr_in *)old; 121d947d4fe15b Samuel Cabrero 2020-11-30 455 121d947d4fe15b Samuel Cabrero 2020-11-30 456 port = ipv4->sin_port; 121d947d4fe15b Samuel Cabrero 2020-11-30 457 } 121d947d4fe15b Samuel Cabrero 2020-11-30 458 121d947d4fe15b Samuel Cabrero 2020-11-30 459 if (old->ss_family == AF_INET6) { 121d947d4fe15b Samuel Cabrero 2020-11-30 460 struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)old; 121d947d4fe15b Samuel Cabrero 2020-11-30 461 121d947d4fe15b Samuel Cabrero 2020-11-30 462 port = ipv6->sin6_port; 121d947d4fe15b Samuel Cabrero 2020-11-30 463 } 121d947d4fe15b Samuel Cabrero 2020-11-30 464 121d947d4fe15b Samuel Cabrero 2020-11-30 465 if (new->ss_family == AF_INET) { 121d947d4fe15b Samuel Cabrero 2020-11-30 466 struct sockaddr_in *ipv4 = (struct sockaddr_in *)new; 121d947d4fe15b Samuel Cabrero 2020-11-30 467 121d947d4fe15b Samuel Cabrero 2020-11-30 @468 ipv4->sin_port = port;
Apparently Smatch is not smart enough to know that AF_INET and AF_INET6 are the only possible values for old->ss_family. I hope that eventually we will be able to enable GCC's uninitialized variable checking and GCC is certainly not able to figure this out either.
121d947d4fe15b Samuel Cabrero 2020-11-30 469 } 121d947d4fe15b Samuel Cabrero 2020-11-30 470 121d947d4fe15b Samuel Cabrero 2020-11-30 471 if (new->ss_family == AF_INET6) { 121d947d4fe15b Samuel Cabrero 2020-11-30 472 struct sockaddr_in6 *ipv6 = (struct sockaddr_in6 *)new; 121d947d4fe15b Samuel Cabrero 2020-11-30 473 121d947d4fe15b Samuel Cabrero 2020-11-30 474 ipv6->sin6_port = port; 121d947d4fe15b Samuel Cabrero 2020-11-30 475 } 121d947d4fe15b Samuel Cabrero 2020-11-30 476 121d947d4fe15b Samuel Cabrero 2020-11-30 477 *dst = *new; 121d947d4fe15b Samuel Cabrero 2020-11-30 478 121d947d4fe15b Samuel Cabrero 2020-11-30 479 return 0; 121d947d4fe15b Samuel Cabrero 2020-11-30 480 }
--- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
| |