drivers/net/ethernet/pensando/ionic/ionic_lif.c:855 ionic_adminq_napi() error: we previously assumed 'lif->adminqcq' could be null (see line 848)

From: Dan Carpenter
Date: Tue Feb 09 2021 - 19:29:02 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: e0756cfc7d7cd08c98a53b6009c091a3f6a50be6
commit: 04a834592bf51355383db6fc00cb09f776a6b8dc ionic: dynamic interrupt moderation
config: s390-randconfig-m031-20210209 (attached as .config)
compiler: s390-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

smatch warnings:
drivers/net/ethernet/pensando/ionic/ionic_lif.c:855 ionic_adminq_napi() error: we previously assumed 'lif->adminqcq' could be null (see line 848)

vim +855 drivers/net/ethernet/pensando/ionic/ionic_lif.c

1d062b7b6f6408 Shannon Nelson 2019-09-03 834 static int ionic_adminq_napi(struct napi_struct *napi, int budget)
1d062b7b6f6408 Shannon Nelson 2019-09-03 835 {
b4280948aa22ab Shannon Nelson 2020-09-01 836 struct ionic_intr_info *intr = napi_to_cq(napi)->bound_intr;
77ceb68e29ccd2 Shannon Nelson 2019-09-03 837 struct ionic_lif *lif = napi_to_cq(napi)->lif;
b4280948aa22ab Shannon Nelson 2020-09-01 838 struct ionic_dev *idev = &lif->ionic->idev;
b4280948aa22ab Shannon Nelson 2020-09-01 839 unsigned int flags = 0;
77ceb68e29ccd2 Shannon Nelson 2019-09-03 840 int n_work = 0;
77ceb68e29ccd2 Shannon Nelson 2019-09-03 841 int a_work = 0;
b4280948aa22ab Shannon Nelson 2020-09-01 842 int work_done;
b4280948aa22ab Shannon Nelson 2020-09-01 843
b4280948aa22ab Shannon Nelson 2020-09-01 844 if (lif->notifyqcq && lif->notifyqcq->flags & IONIC_QCQ_F_INITED)
b4280948aa22ab Shannon Nelson 2020-09-01 845 n_work = ionic_cq_service(&lif->notifyqcq->cq, budget,
b4280948aa22ab Shannon Nelson 2020-09-01 846 ionic_notifyq_service, NULL, NULL);
77ceb68e29ccd2 Shannon Nelson 2019-09-03 847
b4280948aa22ab Shannon Nelson 2020-09-01 @848 if (lif->adminqcq && lif->adminqcq->flags & IONIC_QCQ_F_INITED)
^^^^^^^^^^^^^
Check for NULL

b4280948aa22ab Shannon Nelson 2020-09-01 849 a_work = ionic_cq_service(&lif->adminqcq->cq, budget,
b4280948aa22ab Shannon Nelson 2020-09-01 850 ionic_adminq_service, NULL, NULL);
b4280948aa22ab Shannon Nelson 2020-09-01 851
b4280948aa22ab Shannon Nelson 2020-09-01 852 work_done = max(n_work, a_work);
b4280948aa22ab Shannon Nelson 2020-09-01 853 if (work_done < budget && napi_complete_done(napi, work_done)) {
b4280948aa22ab Shannon Nelson 2020-09-01 854 flags |= IONIC_INTR_CRED_UNMASK;
04a834592bf513 Shannon Nelson 2020-09-15 @855 lif->adminqcq->cq.bound_intr->rearm_count++;
^^^^^^^^^^^^^
Unchecked dereference

b4280948aa22ab Shannon Nelson 2020-09-01 856 }
77ceb68e29ccd2 Shannon Nelson 2019-09-03 857
b4280948aa22ab Shannon Nelson 2020-09-01 858 if (work_done || flags) {
b4280948aa22ab Shannon Nelson 2020-09-01 859 flags |= IONIC_INTR_CRED_RESET_COALESCE;
b4280948aa22ab Shannon Nelson 2020-09-01 860 ionic_intr_credits(idev->intr_ctrl,
b4280948aa22ab Shannon Nelson 2020-09-01 861 intr->index,
b4280948aa22ab Shannon Nelson 2020-09-01 862 n_work + a_work, flags);
b4280948aa22ab Shannon Nelson 2020-09-01 863 }
b4280948aa22ab Shannon Nelson 2020-09-01 864
b4280948aa22ab Shannon Nelson 2020-09-01 865 return work_done;
1d062b7b6f6408 Shannon Nelson 2019-09-03 866 }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip