[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202210240609.shgXn4sF-lkp@intel.com>
Date: Mon, 24 Oct 2022 07:11:31 +0800
From: kernel test robot <lkp@...el.com>
To: KaiLong Wang <wangkailong@...i.cn>, davem@...emloft.net,
yoshfuji@...ux-ipv6.org, dsahern@...nel.org, edumazet@...gle.com,
kuba@...nel.org, pabeni@...hat.com
Cc: kbuild-all@...ts.01.org, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: replace ternary operator with min()
Hi KaiLong,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on net-next/master]
[also build test WARNING on net/master linus/master v6.1-rc1 next-20221021]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/KaiLong-Wang/net-replace-ternary-operator-with-min/20221023-211341
patch link: https://lore.kernel.org/r/4e5c1182.347.18404f42721.Coremail.wangkailong%40jari.cn
patch subject: [PATCH] net: replace ternary operator with min()
config: loongarch-randconfig-s031-20221023
compiler: loongarch64-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/f816f1331754a52709034b8a73ce44ffe4722b90
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review KaiLong-Wang/net-replace-ternary-operator-with-min/20221023-211341
git checkout f816f1331754a52709034b8a73ce44ffe4722b90
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=loongarch SHELL=/bin/bash net/ipv4/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>
sparse warnings: (new ones prefixed by >>)
net/ipv4/igmp.c: note: in included file (through include/linux/igmp.h):
include/uapi/linux/igmp.h:60:32: sparse: sparse: array of flexible structures
>> net/ipv4/igmp.c:2574:21: sparse: sparse: incompatible types in comparison expression (different signedness):
>> net/ipv4/igmp.c:2574:21: sparse: int *
>> net/ipv4/igmp.c:2574:21: sparse: unsigned int *
net/ipv4/igmp.c:2621:21: sparse: sparse: incompatible types in comparison expression (different signedness):
net/ipv4/igmp.c:2621:21: sparse: int *
net/ipv4/igmp.c:2621:21: sparse: unsigned int *
net/ipv4/igmp.c:2933:31: sparse: sparse: context imbalance in 'igmp_mcf_get_next' - unexpected unlock
net/ipv4/igmp.c:2961:9: sparse: sparse: context imbalance in 'igmp_mcf_get_idx' - wrong count at exit
net/ipv4/igmp.c:2978:9: sparse: sparse: context imbalance in 'igmp_mcf_seq_next' - wrong count at exit
net/ipv4/igmp.c: note: in included file (through include/linux/rbtree.h, include/linux/mm_types.h, include/linux/buildid.h, ...):
include/linux/rcupdate.h:781:9: sparse: sparse: context imbalance in 'igmp_mcf_seq_stop' - unexpected unlock
vim +2574 net/ipv4/igmp.c
2441
2442 int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex)
2443 {
2444 int err = 0;
2445 struct ip_mreqn imr;
2446 __be32 addr = msf->imsf_multiaddr;
2447 struct ip_mc_socklist *pmc;
2448 struct in_device *in_dev;
2449 struct inet_sock *inet = inet_sk(sk);
2450 struct ip_sf_socklist *newpsl, *psl;
2451 struct net *net = sock_net(sk);
2452 int leavegroup = 0;
2453
2454 if (!ipv4_is_multicast(addr))
2455 return -EINVAL;
2456 if (msf->imsf_fmode != MCAST_INCLUDE &&
2457 msf->imsf_fmode != MCAST_EXCLUDE)
2458 return -EINVAL;
2459
2460 ASSERT_RTNL();
2461
2462 imr.imr_multiaddr.s_addr = msf->imsf_multiaddr;
2463 imr.imr_address.s_addr = msf->imsf_interface;
2464 imr.imr_ifindex = ifindex;
2465 in_dev = ip_mc_find_dev(net, &imr);
2466
2467 if (!in_dev) {
2468 err = -ENODEV;
2469 goto done;
2470 }
2471
2472 /* special case - (INCLUDE, empty) == LEAVE_GROUP */
2473 if (msf->imsf_fmode == MCAST_INCLUDE && msf->imsf_numsrc == 0) {
2474 leavegroup = 1;
2475 goto done;
2476 }
2477
2478 for_each_pmc_rtnl(inet, pmc) {
2479 if (pmc->multi.imr_multiaddr.s_addr == msf->imsf_multiaddr &&
2480 pmc->multi.imr_ifindex == imr.imr_ifindex)
2481 break;
2482 }
2483 if (!pmc) { /* must have a prior join */
2484 err = -EINVAL;
2485 goto done;
2486 }
2487 if (msf->imsf_numsrc) {
2488 newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr,
2489 msf->imsf_numsrc),
2490 GFP_KERNEL);
2491 if (!newpsl) {
2492 err = -ENOBUFS;
2493 goto done;
2494 }
2495 newpsl->sl_max = newpsl->sl_count = msf->imsf_numsrc;
2496 memcpy(newpsl->sl_addr, msf->imsf_slist_flex,
2497 flex_array_size(msf, imsf_slist_flex, msf->imsf_numsrc));
2498 err = ip_mc_add_src(in_dev, &msf->imsf_multiaddr,
2499 msf->imsf_fmode, newpsl->sl_count, newpsl->sl_addr, 0);
2500 if (err) {
2501 sock_kfree_s(sk, newpsl,
2502 struct_size(newpsl, sl_addr,
2503 newpsl->sl_max));
2504 goto done;
2505 }
2506 } else {
2507 newpsl = NULL;
2508 (void) ip_mc_add_src(in_dev, &msf->imsf_multiaddr,
2509 msf->imsf_fmode, 0, NULL, 0);
2510 }
2511 psl = rtnl_dereference(pmc->sflist);
2512 if (psl) {
2513 (void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode,
2514 psl->sl_count, psl->sl_addr, 0);
2515 /* decrease mem now to avoid the memleak warning */
2516 atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
2517 &sk->sk_omem_alloc);
2518 } else {
2519 (void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode,
2520 0, NULL, 0);
2521 }
2522 rcu_assign_pointer(pmc->sflist, newpsl);
2523 if (psl)
2524 kfree_rcu(psl, rcu);
2525 pmc->sfmode = msf->imsf_fmode;
2526 err = 0;
2527 done:
2528 if (leavegroup)
2529 err = ip_mc_leave_group(sk, &imr);
2530 return err;
2531 }
2532 int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf,
2533 sockptr_t optval, sockptr_t optlen)
2534 {
2535 int err, len, count, copycount, msf_size;
2536 struct ip_mreqn imr;
2537 __be32 addr = msf->imsf_multiaddr;
2538 struct ip_mc_socklist *pmc;
2539 struct in_device *in_dev;
2540 struct inet_sock *inet = inet_sk(sk);
2541 struct ip_sf_socklist *psl;
2542 struct net *net = sock_net(sk);
2543
2544 ASSERT_RTNL();
2545
2546 if (!ipv4_is_multicast(addr))
2547 return -EINVAL;
2548
2549 imr.imr_multiaddr.s_addr = msf->imsf_multiaddr;
2550 imr.imr_address.s_addr = msf->imsf_interface;
2551 imr.imr_ifindex = 0;
2552 in_dev = ip_mc_find_dev(net, &imr);
2553
2554 if (!in_dev) {
2555 err = -ENODEV;
2556 goto done;
2557 }
2558 err = -EADDRNOTAVAIL;
2559
2560 for_each_pmc_rtnl(inet, pmc) {
2561 if (pmc->multi.imr_multiaddr.s_addr == msf->imsf_multiaddr &&
2562 pmc->multi.imr_ifindex == imr.imr_ifindex)
2563 break;
2564 }
2565 if (!pmc) /* must have a prior join */
2566 goto done;
2567 msf->imsf_fmode = pmc->sfmode;
2568 psl = rtnl_dereference(pmc->sflist);
2569 if (!psl) {
2570 count = 0;
2571 } else {
2572 count = psl->sl_count;
2573 }
> 2574 copycount = min(count, msf->imsf_numsrc);
2575 len = flex_array_size(psl, sl_addr, copycount);
2576 msf->imsf_numsrc = count;
2577 msf_size = IP_MSFILTER_SIZE(copycount);
2578 if (copy_to_sockptr(optlen, &msf_size, sizeof(int)) ||
2579 copy_to_sockptr(optval, msf, IP_MSFILTER_SIZE(0))) {
2580 return -EFAULT;
2581 }
2582 if (len &&
2583 copy_to_sockptr_offset(optval,
2584 offsetof(struct ip_msfilter, imsf_slist_flex),
2585 psl->sl_addr, len))
2586 return -EFAULT;
2587 return 0;
2588 done:
2589 return err;
2590 }
2591
--
0-DAY CI Kernel Test Service
https://01.org/lkp
View attachment "config" of type "text/plain" (158543 bytes)
Powered by blists - more mailing lists