All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: net/sched/sch_ets.c:680:23: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
Date: Mon, 11 Jul 2022 10:52:59 +0800	[thread overview]
Message-ID: <202207111005.dzzNPyUa-lkp@intel.com> (raw)

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

:::::: 
:::::: Manual check reason: "low confidence static check warning: net/sched/sch_ets.c:680:23: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]"
:::::: 

CC: llvm(a)lists.linux.dev
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
CC: linux-kernel(a)vger.kernel.org
TO: Davide Caratti <dcaratti@redhat.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   32346491ddf24599decca06190ebca03ff9de7f8
commit: cd9b50adc6bb9ad3f7d244590a389522215865c4 net/sched: ets: fix crash when flipping from 'strict' to 'quantum'
date:   11 months ago
:::::: branch date: 5 hours ago
:::::: commit date: 11 months ago
config: arm-randconfig-c002-20220702 (https://download.01.org/0day-ci/archive/20220711/202207111005.dzzNPyUa-lkp(a)intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project f7a80c3d08d4821e621fc88d6a2e435291f82dff)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=cd9b50adc6bb9ad3f7d244590a389522215865c4
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout cd9b50adc6bb9ad3f7d244590a389522215865c4
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm clang-analyzer 

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>


clang-analyzer warnings: (new ones prefixed by >>)
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   net/bluetooth/hci_request.c:3109:25: note: Taking false branch
           struct hci_dev *hdev = container_of(work, struct hci_dev,
                                  ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   net/bluetooth/hci_request.c:3109:25: note: Loop condition is false.  Exiting loop
           struct hci_dev *hdev = container_of(work, struct hci_dev,
                                  ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:306:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   net/bluetooth/hci_request.c:3112:2: note: 'status' declared without an initial value
           u8 status;
           ^~~~~~~~~
   net/bluetooth/hci_request.c:3116:2: note: Calling 'hci_req_sync'
           hci_req_sync(hdev, le_scan_restart, 0, HCI_CMD_TIMEOUT, &status);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/hci_request.c:281:6: note: Assuming the condition is false
           if (test_bit(HCI_UP, &hdev->flags))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/hci_request.c:281:2: note: Taking false branch
           if (test_bit(HCI_UP, &hdev->flags))
           ^
   net/bluetooth/hci_request.c:287:2: note: Returning without writing to '*hci_status'
           return ret;
           ^
   net/bluetooth/hci_request.c:3116:2: note: Returning from 'hci_req_sync'
           hci_req_sync(hdev, le_scan_restart, 0, HCI_CMD_TIMEOUT, &status);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/hci_request.c:3117:6: note: Branch condition evaluates to a garbage value
           if (status) {
               ^~~~~~
   Suppressed 17 warnings (17 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   16 warnings generated.
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   17 warnings generated.
   net/sched/sch_teql.c:249:4: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
                           err = -EINVAL;
                           ^     ~~~~~~~
   net/sched/sch_teql.c:249:4: note: Value stored to 'err' is never read
                           err = -EINVAL;
                           ^     ~~~~~~~
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   16 warnings generated.
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   19 warnings generated.
   net/sched/sch_atm.c:89:25: warning: Value stored to 'p' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct atm_qdisc_data *p = qdisc_priv(sch);
                                  ^   ~~~~~~~~~~~~~~~
   net/sched/sch_atm.c:89:25: note: Value stored to 'p' during its initialization is never read
           struct atm_qdisc_data *p = qdisc_priv(sch);
                                  ^   ~~~~~~~~~~~~~~~
   net/sched/sch_atm.c:388:2: warning: Value stored to 'result' is never read [clang-analyzer-deadcode.DeadStores]
           result = TC_ACT_OK;     /* be nice to gcc */
           ^
   net/sched/sch_atm.c:388:2: note: Value stored to 'result' is never read
   net/sched/sch_atm.c:604:25: warning: Value stored to 'p' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct atm_qdisc_data *p = qdisc_priv(sch);
                                  ^   ~~~~~~~~~~~~~~~
   net/sched/sch_atm.c:604:25: note: Value stored to 'p' during its initialization is never read
           struct atm_qdisc_data *p = qdisc_priv(sch);
                                  ^   ~~~~~~~~~~~~~~~
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   16 warnings generated.
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   17 warnings generated.
>> net/sched/sch_ets.c:680:23: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
                   q->classes[i].qdisc = queues[i];
                                       ^
   net/sched/sch_ets.c:701:6: note: Assuming 'opt' is non-null
           if (!opt)
               ^~~~
   net/sched/sch_ets.c:701:2: note: Taking false branch
           if (!opt)
           ^
   net/sched/sch_ets.c:704:8: note: Value assigned to field 'nbands'
           err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:705:6: note: Assuming 'err' is 0
           if (err)
               ^~~
   net/sched/sch_ets.c:705:2: note: Taking false branch
           if (err)
           ^
   net/sched/sch_ets.c:709:9: note: Calling 'ets_qdisc_change'
           return ets_qdisc_change(sch, opt, extack);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:591:2: note: 'oldbands' initialized here
           unsigned int oldbands = q->nbands;
           ^~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:598:7: note: 'opt' is non-null
           if (!opt) {
                ^~~
   net/sched/sch_ets.c:598:2: note: Taking false branch
           if (!opt) {
           ^
   net/sched/sch_ets.c:603:8: note: Calling 'nla_parse_nested'
           err = nla_parse_nested(tb, TCA_ETS_MAX, opt, ets_policy, extack);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/net/netlink.h:1207:6: note: Assuming the condition is false
           if (!(nla->nla_type & NLA_F_NESTED)) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/net/netlink.h:1207:2: note: Taking false branch
           if (!(nla->nla_type & NLA_F_NESTED)) {
           ^
   include/net/netlink.h:1212:9: note: Assigning value, which participates in a condition later
           return __nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy,
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:603:8: note: Returning from 'nla_parse_nested'
           err = nla_parse_nested(tb, TCA_ETS_MAX, opt, ets_policy, extack);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:604:6: note: Assuming 'err' is >= 0
           if (err < 0)
               ^~~~~~~
   net/sched/sch_ets.c:604:2: note: Taking false branch
           if (err < 0)
           ^
   net/sched/sch_ets.c:607:6: note: Assuming the condition is false
           if (!tb[TCA_ETS_NBANDS]) {
               ^~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:607:2: note: Taking false branch
           if (!tb[TCA_ETS_NBANDS]) {
           ^
   net/sched/sch_ets.c:612:6: note: Assuming 'nbands' is >= 1
           if (nbands < 1 || nbands > TCQ_ETS_MAX_BANDS) {
               ^~~~~~~~~~
   net/sched/sch_ets.c:612:6: note: Left side of '||' is false
   net/sched/sch_ets.c:612:20: note: Assuming 'nbands' is <= TCQ_ETS_MAX_BANDS
           if (nbands < 1 || nbands > TCQ_ETS_MAX_BANDS) {
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:612:2: note: Taking false branch
           if (nbands < 1 || nbands > TCQ_ETS_MAX_BANDS) {
           ^
   net/sched/sch_ets.c:619:6: note: Assuming the condition is false
           if (tb[TCA_ETS_NSTRICT]) {
               ^~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:619:2: note: Taking false branch
           if (tb[TCA_ETS_NSTRICT]) {
           ^
   net/sched/sch_ets.c:627:6: note: Assuming the condition is false
           if (tb[TCA_ETS_PRIOMAP]) {
               ^~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:627:2: note: Taking false branch
           if (tb[TCA_ETS_PRIOMAP]) {
           ^
   net/sched/sch_ets.c:634:6: note: Assuming the condition is false
           if (tb[TCA_ETS_QUANTA]) {
               ^~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:634:2: note: Taking false branch
           if (tb[TCA_ETS_QUANTA]) {
           ^
   net/sched/sch_ets.c:643:20: note: 'i' is < 'nbands'
           for (i = nstrict; i < nbands; i++) {
                             ^
   net/sched/sch_ets.c:643:2: note: Loop condition is true.  Entering loop body
           for (i = nstrict; i < nbands; i++) {
           ^
   net/sched/sch_ets.c:644:3: note: Taking true branch
                   if (!quanta[i])
                   ^
   net/sched/sch_ets.c:643:20: note: Assuming 'i' is >= 'nbands'
           for (i = nstrict; i < nbands; i++) {
                             ^~~~~~~~~~
   net/sched/sch_ets.c:643:2: note: Loop condition is false. Execution continues on line 649
           for (i = nstrict; i < nbands; i++) {
           ^
   net/sched/sch_ets.c:649:21: note: Assuming 'i' is >= 'nbands'
--
   include/linux/kernel.h:495:61: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
                                                                      ^
   net/bluetooth/hci_request.c:3109:25: note: Taking false branch
           struct hci_dev *hdev = container_of(work, struct hci_dev,
                                  ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:308:3: note: expanded from macro '__compiletime_assert'
                   if (!(condition))                                       \
                   ^
   net/bluetooth/hci_request.c:3109:25: note: Loop condition is false.  Exiting loop
           struct hci_dev *hdev = container_of(work, struct hci_dev,
                                  ^
   include/linux/kernel.h:495:2: note: expanded from macro 'container_of'
           BUILD_BUG_ON_MSG(!__same_type(*(ptr), ((type *)0)->member) &&   \
           ^
   include/linux/build_bug.h:39:37: note: expanded from macro 'BUILD_BUG_ON_MSG'
   #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
                                       ^
   include/linux/compiler_types.h:328:2: note: expanded from macro 'compiletime_assert'
           _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
           ^
   include/linux/compiler_types.h:316:2: note: expanded from macro '_compiletime_assert'
           __compiletime_assert(condition, msg, prefix, suffix)
           ^
   include/linux/compiler_types.h:306:2: note: expanded from macro '__compiletime_assert'
           do {                                                            \
           ^
   net/bluetooth/hci_request.c:3112:2: note: 'status' declared without an initial value
           u8 status;
           ^~~~~~~~~
   net/bluetooth/hci_request.c:3116:2: note: Calling 'hci_req_sync'
           hci_req_sync(hdev, le_scan_restart, 0, HCI_CMD_TIMEOUT, &status);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/hci_request.c:281:6: note: Assuming the condition is false
           if (test_bit(HCI_UP, &hdev->flags))
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/hci_request.c:281:2: note: Taking false branch
           if (test_bit(HCI_UP, &hdev->flags))
           ^
   net/bluetooth/hci_request.c:287:2: note: Returning without writing to '*hci_status'
           return ret;
           ^
   net/bluetooth/hci_request.c:3116:2: note: Returning from 'hci_req_sync'
           hci_req_sync(hdev, le_scan_restart, 0, HCI_CMD_TIMEOUT, &status);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/bluetooth/hci_request.c:3117:6: note: Branch condition evaluates to a garbage value
           if (status) {
               ^~~~~~
   Suppressed 17 warnings (17 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   16 warnings generated.
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   17 warnings generated.
   net/sched/sch_teql.c:249:4: warning: Value stored to 'err' is never read [clang-analyzer-deadcode.DeadStores]
                           err = -EINVAL;
                           ^     ~~~~~~~
   net/sched/sch_teql.c:249:4: note: Value stored to 'err' is never read
                           err = -EINVAL;
                           ^     ~~~~~~~
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   16 warnings generated.
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   19 warnings generated.
   net/sched/sch_atm.c:89:25: warning: Value stored to 'p' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct atm_qdisc_data *p = qdisc_priv(sch);
                                  ^   ~~~~~~~~~~~~~~~
   net/sched/sch_atm.c:89:25: note: Value stored to 'p' during its initialization is never read
           struct atm_qdisc_data *p = qdisc_priv(sch);
                                  ^   ~~~~~~~~~~~~~~~
   net/sched/sch_atm.c:388:2: warning: Value stored to 'result' is never read [clang-analyzer-deadcode.DeadStores]
           result = TC_ACT_OK;     /* be nice to gcc */
           ^
   net/sched/sch_atm.c:388:2: note: Value stored to 'result' is never read
   net/sched/sch_atm.c:604:25: warning: Value stored to 'p' during its initialization is never read [clang-analyzer-deadcode.DeadStores]
           struct atm_qdisc_data *p = qdisc_priv(sch);
                                  ^   ~~~~~~~~~~~~~~~
   net/sched/sch_atm.c:604:25: note: Value stored to 'p' during its initialization is never read
           struct atm_qdisc_data *p = qdisc_priv(sch);
                                  ^   ~~~~~~~~~~~~~~~
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   16 warnings generated.
   Suppressed 16 warnings (16 in non-user code).
   Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
   17 warnings generated.
>> net/sched/sch_ets.c:680:23: warning: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign]
                   q->classes[i].qdisc = queues[i];
                                       ^
   net/sched/sch_ets.c:701:6: note: Assuming 'opt' is non-null
           if (!opt)
               ^~~~
   net/sched/sch_ets.c:701:2: note: Taking false branch
           if (!opt)
           ^
   net/sched/sch_ets.c:704:8: note: Value assigned to field 'nbands'
           err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:705:6: note: Assuming 'err' is 0
           if (err)
               ^~~
   net/sched/sch_ets.c:705:2: note: Taking false branch
           if (err)
           ^
   net/sched/sch_ets.c:709:9: note: Calling 'ets_qdisc_change'
           return ets_qdisc_change(sch, opt, extack);
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:591:2: note: 'oldbands' initialized here
           unsigned int oldbands = q->nbands;
           ^~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:598:7: note: 'opt' is non-null
           if (!opt) {
                ^~~
   net/sched/sch_ets.c:598:2: note: Taking false branch
           if (!opt) {
           ^
   net/sched/sch_ets.c:603:8: note: Calling 'nla_parse_nested'
           err = nla_parse_nested(tb, TCA_ETS_MAX, opt, ets_policy, extack);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/net/netlink.h:1207:6: note: Assuming the condition is false
           if (!(nla->nla_type & NLA_F_NESTED)) {
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/net/netlink.h:1207:2: note: Taking false branch
           if (!(nla->nla_type & NLA_F_NESTED)) {
           ^
   include/net/netlink.h:1212:9: note: Assigning value, which participates in a condition later
           return __nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy,
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:603:8: note: Returning from 'nla_parse_nested'
           err = nla_parse_nested(tb, TCA_ETS_MAX, opt, ets_policy, extack);
                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:604:6: note: Assuming 'err' is >= 0
           if (err < 0)
               ^~~~~~~
   net/sched/sch_ets.c:604:2: note: Taking false branch
           if (err < 0)
           ^
   net/sched/sch_ets.c:607:6: note: Assuming the condition is false
           if (!tb[TCA_ETS_NBANDS]) {
               ^~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:607:2: note: Taking false branch
           if (!tb[TCA_ETS_NBANDS]) {
           ^
   net/sched/sch_ets.c:612:6: note: Assuming 'nbands' is >= 1
           if (nbands < 1 || nbands > TCQ_ETS_MAX_BANDS) {
               ^~~~~~~~~~
   net/sched/sch_ets.c:612:6: note: Left side of '||' is false
   net/sched/sch_ets.c:612:20: note: Assuming 'nbands' is <= TCQ_ETS_MAX_BANDS
           if (nbands < 1 || nbands > TCQ_ETS_MAX_BANDS) {
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:612:2: note: Taking false branch
           if (nbands < 1 || nbands > TCQ_ETS_MAX_BANDS) {
           ^
   net/sched/sch_ets.c:619:6: note: Assuming the condition is false
           if (tb[TCA_ETS_NSTRICT]) {
               ^~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:619:2: note: Taking false branch
           if (tb[TCA_ETS_NSTRICT]) {
           ^
   net/sched/sch_ets.c:627:6: note: Assuming the condition is false
           if (tb[TCA_ETS_PRIOMAP]) {
               ^~~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:627:2: note: Taking false branch
           if (tb[TCA_ETS_PRIOMAP]) {
           ^
   net/sched/sch_ets.c:634:6: note: Assuming the condition is false
           if (tb[TCA_ETS_QUANTA]) {
               ^~~~~~~~~~~~~~~~~~
   net/sched/sch_ets.c:634:2: note: Taking false branch
           if (tb[TCA_ETS_QUANTA]) {
           ^
   net/sched/sch_ets.c:643:20: note: 'i' is < 'nbands'
           for (i = nstrict; i < nbands; i++) {
                             ^
   net/sched/sch_ets.c:643:2: note: Loop condition is true.  Entering loop body
           for (i = nstrict; i < nbands; i++) {
           ^
   net/sched/sch_ets.c:644:3: note: Taking true branch
                   if (!quanta[i])
                   ^
   net/sched/sch_ets.c:643:20: note: Assuming 'i' is >= 'nbands'
           for (i = nstrict; i < nbands; i++) {
                             ^~~~~~~~~~
   net/sched/sch_ets.c:643:2: note: Loop condition is false. Execution continues on line 649
           for (i = nstrict; i < nbands; i++) {
           ^
   net/sched/sch_ets.c:649:21: note: Assuming 'i' is >= 'nbands'

vim +680 net/sched/sch_ets.c

dcc68b4d8084e1 Petr Machata   2019-12-18  583  
dcc68b4d8084e1 Petr Machata   2019-12-18  584  static int ets_qdisc_change(struct Qdisc *sch, struct nlattr *opt,
dcc68b4d8084e1 Petr Machata   2019-12-18  585  			    struct netlink_ext_ack *extack)
dcc68b4d8084e1 Petr Machata   2019-12-18  586  {
dcc68b4d8084e1 Petr Machata   2019-12-18  587  	unsigned int quanta[TCQ_ETS_MAX_BANDS] = {0};
dcc68b4d8084e1 Petr Machata   2019-12-18  588  	struct Qdisc *queues[TCQ_ETS_MAX_BANDS];
dcc68b4d8084e1 Petr Machata   2019-12-18  589  	struct ets_sched *q = qdisc_priv(sch);
dcc68b4d8084e1 Petr Machata   2019-12-18  590  	struct nlattr *tb[TCA_ETS_MAX + 1];
dcc68b4d8084e1 Petr Machata   2019-12-18  591  	unsigned int oldbands = q->nbands;
dcc68b4d8084e1 Petr Machata   2019-12-18  592  	u8 priomap[TC_PRIO_MAX + 1];
dcc68b4d8084e1 Petr Machata   2019-12-18  593  	unsigned int nstrict = 0;
dcc68b4d8084e1 Petr Machata   2019-12-18  594  	unsigned int nbands;
dcc68b4d8084e1 Petr Machata   2019-12-18  595  	unsigned int i;
dcc68b4d8084e1 Petr Machata   2019-12-18  596  	int err;
dcc68b4d8084e1 Petr Machata   2019-12-18  597  
dcc68b4d8084e1 Petr Machata   2019-12-18  598  	if (!opt) {
dcc68b4d8084e1 Petr Machata   2019-12-18  599  		NL_SET_ERR_MSG(extack, "ETS options are required for this operation");
dcc68b4d8084e1 Petr Machata   2019-12-18  600  		return -EINVAL;
dcc68b4d8084e1 Petr Machata   2019-12-18  601  	}
dcc68b4d8084e1 Petr Machata   2019-12-18  602  
dcc68b4d8084e1 Petr Machata   2019-12-18  603  	err = nla_parse_nested(tb, TCA_ETS_MAX, opt, ets_policy, extack);
dcc68b4d8084e1 Petr Machata   2019-12-18  604  	if (err < 0)
dcc68b4d8084e1 Petr Machata   2019-12-18  605  		return err;
dcc68b4d8084e1 Petr Machata   2019-12-18  606  
dcc68b4d8084e1 Petr Machata   2019-12-18  607  	if (!tb[TCA_ETS_NBANDS]) {
dcc68b4d8084e1 Petr Machata   2019-12-18  608  		NL_SET_ERR_MSG_MOD(extack, "Number of bands is a required argument");
dcc68b4d8084e1 Petr Machata   2019-12-18  609  		return -EINVAL;
dcc68b4d8084e1 Petr Machata   2019-12-18  610  	}
dcc68b4d8084e1 Petr Machata   2019-12-18  611  	nbands = nla_get_u8(tb[TCA_ETS_NBANDS]);
dcc68b4d8084e1 Petr Machata   2019-12-18  612  	if (nbands < 1 || nbands > TCQ_ETS_MAX_BANDS) {
dcc68b4d8084e1 Petr Machata   2019-12-18  613  		NL_SET_ERR_MSG_MOD(extack, "Invalid number of bands");
dcc68b4d8084e1 Petr Machata   2019-12-18  614  		return -EINVAL;
dcc68b4d8084e1 Petr Machata   2019-12-18  615  	}
dcc68b4d8084e1 Petr Machata   2019-12-18  616  	/* Unless overridden, traffic goes to the last band. */
dcc68b4d8084e1 Petr Machata   2019-12-18  617  	memset(priomap, nbands - 1, sizeof(priomap));
dcc68b4d8084e1 Petr Machata   2019-12-18  618  
dcc68b4d8084e1 Petr Machata   2019-12-18  619  	if (tb[TCA_ETS_NSTRICT]) {
dcc68b4d8084e1 Petr Machata   2019-12-18  620  		nstrict = nla_get_u8(tb[TCA_ETS_NSTRICT]);
dcc68b4d8084e1 Petr Machata   2019-12-18  621  		if (nstrict > nbands) {
dcc68b4d8084e1 Petr Machata   2019-12-18  622  			NL_SET_ERR_MSG_MOD(extack, "Invalid number of strict bands");
dcc68b4d8084e1 Petr Machata   2019-12-18  623  			return -EINVAL;
dcc68b4d8084e1 Petr Machata   2019-12-18  624  		}
dcc68b4d8084e1 Petr Machata   2019-12-18  625  	}
dcc68b4d8084e1 Petr Machata   2019-12-18  626  
dcc68b4d8084e1 Petr Machata   2019-12-18  627  	if (tb[TCA_ETS_PRIOMAP]) {
dcc68b4d8084e1 Petr Machata   2019-12-18  628  		err = ets_qdisc_priomap_parse(tb[TCA_ETS_PRIOMAP],
dcc68b4d8084e1 Petr Machata   2019-12-18  629  					      nbands, priomap, extack);
dcc68b4d8084e1 Petr Machata   2019-12-18  630  		if (err)
dcc68b4d8084e1 Petr Machata   2019-12-18  631  			return err;
dcc68b4d8084e1 Petr Machata   2019-12-18  632  	}
dcc68b4d8084e1 Petr Machata   2019-12-18  633  
dcc68b4d8084e1 Petr Machata   2019-12-18  634  	if (tb[TCA_ETS_QUANTA]) {
dcc68b4d8084e1 Petr Machata   2019-12-18  635  		err = ets_qdisc_quanta_parse(sch, tb[TCA_ETS_QUANTA],
dcc68b4d8084e1 Petr Machata   2019-12-18  636  					     nbands, nstrict, quanta, extack);
dcc68b4d8084e1 Petr Machata   2019-12-18  637  		if (err)
dcc68b4d8084e1 Petr Machata   2019-12-18  638  			return err;
dcc68b4d8084e1 Petr Machata   2019-12-18  639  	}
dcc68b4d8084e1 Petr Machata   2019-12-18  640  	/* If there are more bands than strict + quanta provided, the remaining
dcc68b4d8084e1 Petr Machata   2019-12-18  641  	 * ones are ETS with quantum of MTU. Initialize the missing values here.
dcc68b4d8084e1 Petr Machata   2019-12-18  642  	 */
dcc68b4d8084e1 Petr Machata   2019-12-18  643  	for (i = nstrict; i < nbands; i++) {
dcc68b4d8084e1 Petr Machata   2019-12-18  644  		if (!quanta[i])
dcc68b4d8084e1 Petr Machata   2019-12-18  645  			quanta[i] = psched_mtu(qdisc_dev(sch));
dcc68b4d8084e1 Petr Machata   2019-12-18  646  	}
dcc68b4d8084e1 Petr Machata   2019-12-18  647  
dcc68b4d8084e1 Petr Machata   2019-12-18  648  	/* Before commit, make sure we can allocate all new qdiscs */
dcc68b4d8084e1 Petr Machata   2019-12-18  649  	for (i = oldbands; i < nbands; i++) {
dcc68b4d8084e1 Petr Machata   2019-12-18  650  		queues[i] = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops,
dcc68b4d8084e1 Petr Machata   2019-12-18  651  					      ets_class_id(sch, &q->classes[i]),
dcc68b4d8084e1 Petr Machata   2019-12-18  652  					      extack);
dcc68b4d8084e1 Petr Machata   2019-12-18  653  		if (!queues[i]) {
dcc68b4d8084e1 Petr Machata   2019-12-18  654  			while (i > oldbands)
dcc68b4d8084e1 Petr Machata   2019-12-18  655  				qdisc_put(queues[--i]);
dcc68b4d8084e1 Petr Machata   2019-12-18  656  			return -ENOMEM;
dcc68b4d8084e1 Petr Machata   2019-12-18  657  		}
dcc68b4d8084e1 Petr Machata   2019-12-18  658  	}
dcc68b4d8084e1 Petr Machata   2019-12-18  659  
dcc68b4d8084e1 Petr Machata   2019-12-18  660  	sch_tree_lock(sch);
dcc68b4d8084e1 Petr Machata   2019-12-18  661  
dcc68b4d8084e1 Petr Machata   2019-12-18  662  	q->nbands = nbands;
cd9b50adc6bb9a Davide Caratti 2021-08-25  663  	for (i = nstrict; i < q->nstrict; i++) {
cd9b50adc6bb9a Davide Caratti 2021-08-25  664  		INIT_LIST_HEAD(&q->classes[i].alist);
cd9b50adc6bb9a Davide Caratti 2021-08-25  665  		if (q->classes[i].qdisc->q.qlen) {
cd9b50adc6bb9a Davide Caratti 2021-08-25  666  			list_add_tail(&q->classes[i].alist, &q->active);
cd9b50adc6bb9a Davide Caratti 2021-08-25  667  			q->classes[i].deficit = quanta[i];
cd9b50adc6bb9a Davide Caratti 2021-08-25  668  		}
cd9b50adc6bb9a Davide Caratti 2021-08-25  669  	}
dcc68b4d8084e1 Petr Machata   2019-12-18  670  	q->nstrict = nstrict;
dcc68b4d8084e1 Petr Machata   2019-12-18  671  	memcpy(q->prio2band, priomap, sizeof(priomap));
dcc68b4d8084e1 Petr Machata   2019-12-18  672  
dcc68b4d8084e1 Petr Machata   2019-12-18  673  	for (i = q->nbands; i < oldbands; i++)
dcc68b4d8084e1 Petr Machata   2019-12-18  674  		qdisc_tree_flush_backlog(q->classes[i].qdisc);
dcc68b4d8084e1 Petr Machata   2019-12-18  675  
dcc68b4d8084e1 Petr Machata   2019-12-18  676  	for (i = 0; i < q->nbands; i++)
dcc68b4d8084e1 Petr Machata   2019-12-18  677  		q->classes[i].quantum = quanta[i];
dcc68b4d8084e1 Petr Machata   2019-12-18  678  
dcc68b4d8084e1 Petr Machata   2019-12-18  679  	for (i = oldbands; i < q->nbands; i++) {
dcc68b4d8084e1 Petr Machata   2019-12-18 @680  		q->classes[i].qdisc = queues[i];
dcc68b4d8084e1 Petr Machata   2019-12-18  681  		if (q->classes[i].qdisc != &noop_qdisc)
dcc68b4d8084e1 Petr Machata   2019-12-18  682  			qdisc_hash_add(q->classes[i].qdisc, true);
dcc68b4d8084e1 Petr Machata   2019-12-18  683  	}
dcc68b4d8084e1 Petr Machata   2019-12-18  684  
dcc68b4d8084e1 Petr Machata   2019-12-18  685  	sch_tree_unlock(sch);
dcc68b4d8084e1 Petr Machata   2019-12-18  686  
d35eb52bd2ac75 Petr Machata   2019-12-18  687  	ets_offload_change(sch);
dcc68b4d8084e1 Petr Machata   2019-12-18  688  	for (i = q->nbands; i < oldbands; i++) {
dcc68b4d8084e1 Petr Machata   2019-12-18  689  		qdisc_put(q->classes[i].qdisc);
dcc68b4d8084e1 Petr Machata   2019-12-18  690  		memset(&q->classes[i], 0, sizeof(q->classes[i]));
dcc68b4d8084e1 Petr Machata   2019-12-18  691  	}
dcc68b4d8084e1 Petr Machata   2019-12-18  692  	return 0;
dcc68b4d8084e1 Petr Machata   2019-12-18  693  }
dcc68b4d8084e1 Petr Machata   2019-12-18  694  

:::::: The code at line 680 was first introduced by commit
:::::: dcc68b4d8084e1ac9af0d4022d6b1aff6a139a33 net: sch_ets: Add a new Qdisc

:::::: TO: Petr Machata <petrm@mellanox.com>
:::::: CC: David S. Miller <davem@davemloft.net>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

                 reply	other threads:[~2022-07-11  2:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202207111005.dzzNPyUa-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.