drivers/net/ethernet/intel/i40e/i40e_debugfs.c:582 i40e_dbg_dump_desc() error: uninitialized symbol 'ring'.

From: Dan Carpenter
Date: Tue Oct 06 2020 - 08:45:43 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 60e720931556fc1034d0981460164dcf02697679
commit: 44ea803e2fa7e12adb5d6260da4e4956e784effb i40e: introduce new dump desc XDP command
config: i386-randconfig-m021-20201001 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 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/intel/i40e/i40e_debugfs.c:582 i40e_dbg_dump_desc() error: uninitialized symbol 'ring'.

vim +/ring +582 drivers/net/ethernet/intel/i40e/i40e_debugfs.c

02e9c290814cc14 Jesse Brandeburg 2013-09-11 541 static void i40e_dbg_dump_desc(int cnt, int vsi_seid, int ring_id, int desc_n,
44ea803e2fa7e12 Ciara Loftus 2020-06-23 542 struct i40e_pf *pf, enum ring_type type)
02e9c290814cc14 Jesse Brandeburg 2013-09-11 543 {
44ea803e2fa7e12 Ciara Loftus 2020-06-23 544 bool is_rx_ring = type == RING_TYPE_RX;
68bf94aae1873cb Shannon Nelson 2014-01-15 545 struct i40e_tx_desc *txd;
68bf94aae1873cb Shannon Nelson 2014-01-15 546 union i40e_rx_desc *rxd;
e6c97234d1b18d4 Joe Perches 2014-11-18 547 struct i40e_ring *ring;
02e9c290814cc14 Jesse Brandeburg 2013-09-11 548 struct i40e_vsi *vsi;
02e9c290814cc14 Jesse Brandeburg 2013-09-11 549 int i;
02e9c290814cc14 Jesse Brandeburg 2013-09-11 550
02e9c290814cc14 Jesse Brandeburg 2013-09-11 551 vsi = i40e_dbg_find_vsi(pf, vsi_seid);
02e9c290814cc14 Jesse Brandeburg 2013-09-11 552 if (!vsi) {
7792fe4fd2f1fac Shannon Nelson 2013-11-26 553 dev_info(&pf->pdev->dev, "vsi %d not found\n", vsi_seid);
02e9c290814cc14 Jesse Brandeburg 2013-09-11 554 return;
02e9c290814cc14 Jesse Brandeburg 2013-09-11 555 }
44ea803e2fa7e12 Ciara Loftus 2020-06-23 556 if (type == RING_TYPE_XDP && !i40e_enabled_xdp_vsi(vsi)) {
44ea803e2fa7e12 Ciara Loftus 2020-06-23 557 dev_info(&pf->pdev->dev, "XDP not enabled on VSI %d\n", vsi_seid);
44ea803e2fa7e12 Ciara Loftus 2020-06-23 558 return;
44ea803e2fa7e12 Ciara Loftus 2020-06-23 559 }
02e9c290814cc14 Jesse Brandeburg 2013-09-11 560 if (ring_id >= vsi->num_queue_pairs || ring_id < 0) {
02e9c290814cc14 Jesse Brandeburg 2013-09-11 561 dev_info(&pf->pdev->dev, "ring %d not found\n", ring_id);
02e9c290814cc14 Jesse Brandeburg 2013-09-11 562 return;
02e9c290814cc14 Jesse Brandeburg 2013-09-11 563 }
68bf94aae1873cb Shannon Nelson 2014-01-15 564 if (!vsi->tx_rings || !vsi->tx_rings[0]->desc) {
29d0790ef3acd86 Shannon Nelson 2013-11-26 565 dev_info(&pf->pdev->dev,
29d0790ef3acd86 Shannon Nelson 2013-11-26 566 "descriptor rings have not been allocated for vsi %d\n",
29d0790ef3acd86 Shannon Nelson 2013-11-26 567 vsi_seid);
29d0790ef3acd86 Shannon Nelson 2013-11-26 568 return;
29d0790ef3acd86 Shannon Nelson 2013-11-26 569 }
e6c97234d1b18d4 Joe Perches 2014-11-18 570
44ea803e2fa7e12 Ciara Loftus 2020-06-23 571 switch (type) {
44ea803e2fa7e12 Ciara Loftus 2020-06-23 572 case RING_TYPE_RX:
44ea803e2fa7e12 Ciara Loftus 2020-06-23 573 ring = kmemdup(vsi->rx_rings[ring_id], sizeof(*ring), GFP_KERNEL);
44ea803e2fa7e12 Ciara Loftus 2020-06-23 574 break;
44ea803e2fa7e12 Ciara Loftus 2020-06-23 575 case RING_TYPE_TX:
44ea803e2fa7e12 Ciara Loftus 2020-06-23 576 ring = kmemdup(vsi->tx_rings[ring_id], sizeof(*ring), GFP_KERNEL);
44ea803e2fa7e12 Ciara Loftus 2020-06-23 577 break;
44ea803e2fa7e12 Ciara Loftus 2020-06-23 578 case RING_TYPE_XDP:
44ea803e2fa7e12 Ciara Loftus 2020-06-23 579 ring = kmemdup(vsi->xdp_rings[ring_id], sizeof(*ring), GFP_KERNEL);
44ea803e2fa7e12 Ciara Loftus 2020-06-23 580 break;

Add default case?

44ea803e2fa7e12 Ciara Loftus 2020-06-23 581 }
e6c97234d1b18d4 Joe Perches 2014-11-18 @582 if (!ring)
^^^^^
e6c97234d1b18d4 Joe Perches 2014-11-18 583 return;
e6c97234d1b18d4 Joe Perches 2014-11-18 584
02e9c290814cc14 Jesse Brandeburg 2013-09-11 585 if (cnt == 2) {
44ea803e2fa7e12 Ciara Loftus 2020-06-23 586 switch (type) {
44ea803e2fa7e12 Ciara Loftus 2020-06-23 587 case RING_TYPE_RX:

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

Attachment: .config.gz
Description: application/gzip