Skip to contentSkip to conversation

net: hns3: add log for setting tx spare buf size

bug report Dan Carpenter 1 participant 1 message Apr 22, 2022 Kernel janitors

lore
Share & tools
lore
#0 lore raw

Hello Hao Chen,

This is a semi-automatic email about new static checker warnings.

The patch 2373b35c24ff: "net: hns3: add log for setting tx spare buf size" from Apr 19, 2022, leads to the following Smatch complaint:

    drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c:1919 hns3_set_tunable()
    error: we previously assumed 'priv->ring->tx_spare' could be null (see line 1904)

drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c
1903 if (ret ||

  1904			    (!priv->ring->tx_spare && new_tx_spare_buf_size != 0)) {
                             ^^^^^^^^^^^^^^^^^^^^^

Assume priv->ring->tx_spare is NULL but new_tx_spare_buf_size is non-zero.

1905 int ret1;
1906
1907 netdev_warn(netdev, "change tx spare buf size fail, revert to old value\n");
1908 ret1 = hns3_set_tx_spare_buf_size(netdev,
1909 old_tx_spare_buf_size);
1910 if (ret1) {
1911 netdev_err(netdev, "revert to old tx spare buf size fail\n");
1912 return ret1;
1913 }
1914
1915 return ret;
1916 }
1917
1918 netdev_info(netdev, "the actvie tx spare buf size is %u, due to page order\n",

  1919				    priv->ring->tx_spare->len);
                                    ^^^^^^^^^^^^^^^^^^^^^^

Unchecked dereference.

1920
1921 break;

regards,
dan carpenter