Re: [PATCH net-next 3/3] net: ethernet: ti: cpsw: add XDP support

From: Dan Carpenter
Date: Mon May 27 2019 - 03:21:33 EST


Hi Ivan,

Thank you for the patch! Perhaps something to improve:

url: https://github.com/0day-ci/linux/commits/Ivan-Khoronzhuk/net-ethernet-ti-cpsw-Add-XDP-support/20190524-114123

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

smatch warnings:
drivers/net/ethernet/ti/cpsw_ethtool.c:564 cpsw_xdp_rxq_reg() error: uninitialized symbol 'ret'.

# https://github.com/0day-ci/linux/commit/3cf4eb125ed19d18340fd3b0c4d7eb2f1ebdfb28
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout 3cf4eb125ed19d18340fd3b0c4d7eb2f1ebdfb28
vim +/ret +564 drivers/net/ethernet/ti/cpsw_ethtool.c

c24eef28 Grygorii Strashko 2019-04-26 534
3cf4eb12 Ivan Khoronzhuk 2019-05-23 535 static int cpsw_xdp_rxq_reg(struct cpsw_common *cpsw, int ch)
3cf4eb12 Ivan Khoronzhuk 2019-05-23 536 {
3cf4eb12 Ivan Khoronzhuk 2019-05-23 537 struct cpsw_slave *slave;
3cf4eb12 Ivan Khoronzhuk 2019-05-23 538 struct cpsw_priv *priv;
3cf4eb12 Ivan Khoronzhuk 2019-05-23 539 int i, ret;
3cf4eb12 Ivan Khoronzhuk 2019-05-23 540
3cf4eb12 Ivan Khoronzhuk 2019-05-23 541 /* As channels are common for both ports sharing same queues, xdp_rxq
3cf4eb12 Ivan Khoronzhuk 2019-05-23 542 * information also becomes shared and used by every packet on this
3cf4eb12 Ivan Khoronzhuk 2019-05-23 543 * channel. But exch xdp_rxq holds link on netdev, which by the theory
3cf4eb12 Ivan Khoronzhuk 2019-05-23 544 * can have different memory model and so, network device must hold it's
3cf4eb12 Ivan Khoronzhuk 2019-05-23 545 * own set of rxq and thus both netdevs should be prepared
3cf4eb12 Ivan Khoronzhuk 2019-05-23 546 */
3cf4eb12 Ivan Khoronzhuk 2019-05-23 547 for (i = cpsw->data.slaves, slave = cpsw->slaves; i; i--, slave++) {
3cf4eb12 Ivan Khoronzhuk 2019-05-23 548 if (!slave->ndev)
3cf4eb12 Ivan Khoronzhuk 2019-05-23 549 continue;

Smatch always complains that every loop iteration could continue. Or
that cpsw->data.slaves might be zero at the start... It seems
implausible.

3cf4eb12 Ivan Khoronzhuk 2019-05-23 550
3cf4eb12 Ivan Khoronzhuk 2019-05-23 551 priv = netdev_priv(slave->ndev);
3cf4eb12 Ivan Khoronzhuk 2019-05-23 552
3cf4eb12 Ivan Khoronzhuk 2019-05-23 553 ret = xdp_rxq_info_reg(&priv->xdp_rxq[ch], priv->ndev, ch);
3cf4eb12 Ivan Khoronzhuk 2019-05-23 554 if (ret)
3cf4eb12 Ivan Khoronzhuk 2019-05-23 555 goto err;
3cf4eb12 Ivan Khoronzhuk 2019-05-23 556
3cf4eb12 Ivan Khoronzhuk 2019-05-23 557 ret = xdp_rxq_info_reg_mem_model(&priv->xdp_rxq[ch],
3cf4eb12 Ivan Khoronzhuk 2019-05-23 558 MEM_TYPE_PAGE_POOL,
3cf4eb12 Ivan Khoronzhuk 2019-05-23 559 cpsw->rx_page_pool);
3cf4eb12 Ivan Khoronzhuk 2019-05-23 560 if (ret)
3cf4eb12 Ivan Khoronzhuk 2019-05-23 561 goto err;
3cf4eb12 Ivan Khoronzhuk 2019-05-23 562 }
3cf4eb12 Ivan Khoronzhuk 2019-05-23 563
3cf4eb12 Ivan Khoronzhuk 2019-05-23 @564 return ret;

This would be more readable as "return 0;" anyway.

3cf4eb12 Ivan Khoronzhuk 2019-05-23 565
3cf4eb12 Ivan Khoronzhuk 2019-05-23 566 err:
3cf4eb12 Ivan Khoronzhuk 2019-05-23 567 cpsw_xdp_rxq_unreg(cpsw, ch);
3cf4eb12 Ivan Khoronzhuk 2019-05-23 568 return ret;
3cf4eb12 Ivan Khoronzhuk 2019-05-23 569 }

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation