All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: virtualization@lists.linux.dev
Subject: [bug report] virtio_net: xsk: bind/unbind xsk for rx
Date: Fri, 10 Apr 2026 13:13:24 +0300	[thread overview]
Message-ID: <adjNRD31OBaVl4He@stanley.mountain> (raw)

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

                 reply	other threads:[~2026-04-10 10:13 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=adjNRD31OBaVl4He@stanley.mountain \
    --to=error27@gmail.com \
    --cc=virtualization@lists.linux.dev \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.