Hello Xuan Zhuo,
Commit 09d2b3182c8e ("virtio_net: xsk: bind/unbind xsk for rx") from
Jul 8, 2024 (linux-next), leads to the following Smatch static
checker warning:
drivers/net/virtio_net.c:5893 virtnet_xsk_pool_enable()
warn: potential bounds check after use 'qid'
drivers/net/virtio_net.c
5873 static int virtnet_xsk_pool_enable(struct net_device *dev,
5874 struct xsk_buff_pool *pool,
5875 u16 qid)
5876 {
5877 struct virtnet_info *vi = netdev_priv(dev);
5878 struct receive_queue *rq;
5879 struct device *dma_dev;
5880 struct send_queue *sq;
5881 dma_addr_t hdr_dma;
5882 int err, size;
5883
5884 if (vi->hdr_len > xsk_pool_get_headroom(pool))
5885 return -EINVAL;
5886
5887 /* In big_packets mode, xdp cannot work, so there is no need to
5888 * initialize xsk of rq.
5889 */
5890 if (!vi->rq[qid].page_pool)
^^^
flip these two checks around
5891 return -ENOENT;
5892
--> 5893 if (qid >= vi->curr_queue_pairs)
^^^
So that we check that qid is valid before using it as an index into the
->rq[] array?
5894 return -EINVAL;
5895
5896 sq = &vi->sq[qid];
5897 rq = &vi->rq[qid];
5898
5899 /* xsk assumes that tx and rx must have the same dma device.
The af-xdp
This email is a free service from the Smatch-CI project [smatch.sf.net].
regards,
dan carpenter