[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1739761322.950906-1-xuanzhuo@linux.alibaba.com>
Date: Mon, 17 Feb 2025 11:02:02 +0800
From: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
To: kernel test robot <lkp@...el.com>
Cc: oe-kbuild-all@...ts.linux.dev,
linux-kernel@...r.kernel.org,
Jakub Kicinski <kuba@...nel.org>
Subject: Re: drivers/net/virtio_net.c:1227 xsk_append_merge_buffer() warn: unsigned '_x' is never less than zero.
On Sun, 16 Feb 2025 11:13:14 +0800, kernel test robot <lkp@...el.com> wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 496659003dac5d08ea292c44fce9dfb36fa34691
> commit: 99c861b44eb1fb9dfe8776854116a6a9064c19bb virtio_net: xsk: rx: support recv merge mode
> date: 7 months ago
> config: riscv-randconfig-r073-20250213 (https://download.01.org/0day-ci/archive/20250216/202502161158.KmluxANz-lkp@intel.com/config)
> compiler: riscv32-linux-gcc (GCC) 14.2.0
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@...el.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202502161158.KmluxANz-lkp@intel.com/
>
> New smatch warnings:
> drivers/net/virtio_net.c:1227 xsk_append_merge_buffer() warn: unsigned '_x' is never less than zero.
This seems to be in the mm system.
Thanks.
>
> Old smatch warnings:
> include/linux/mm.h:1311 virt_to_head_page() warn: unsigned '_x' is never less than zero.
> include/linux/scatterlist.h:189 sg_set_buf() warn: unsigned '_x' is never less than zero.
> drivers/net/virtio_net.c:1934 build_skb_from_xdp_buff() error: uninitialized symbol 'nr_frags'.
> drivers/net/virtio_net.c:2016 virtnet_build_xdp_buff_mrg() error: uninitialized symbol 'shinfo'.
> drivers/net/virtio_net.c:5096 virtnet_update_settings() error: uninitialized symbol 'virtio_cread_v'.
> drivers/net/virtio_net.c:5804 virtnet_config_changed_work() error: uninitialized symbol 'virtio_cread_v'.
> drivers/net/virtio_net.c:5808 virtnet_config_changed_work() error: uninitialized symbol 'v'.
>
> vim +/_x +1227 drivers/net/virtio_net.c
>
> 1184
> 1185 static int xsk_append_merge_buffer(struct virtnet_info *vi,
> 1186 struct receive_queue *rq,
> 1187 struct sk_buff *head_skb,
> 1188 u32 num_buf,
> 1189 struct virtio_net_hdr_mrg_rxbuf *hdr,
> 1190 struct virtnet_rq_stats *stats)
> 1191 {
> 1192 struct sk_buff *curr_skb;
> 1193 struct xdp_buff *xdp;
> 1194 u32 len, truesize;
> 1195 struct page *page;
> 1196 void *buf;
> 1197
> 1198 curr_skb = head_skb;
> 1199
> 1200 while (--num_buf) {
> 1201 buf = virtqueue_get_buf(rq->vq, &len);
> 1202 if (unlikely(!buf)) {
> 1203 pr_debug("%s: rx error: %d buffers out of %d missing\n",
> 1204 vi->dev->name, num_buf,
> 1205 virtio16_to_cpu(vi->vdev,
> 1206 hdr->num_buffers));
> 1207 DEV_STATS_INC(vi->dev, rx_length_errors);
> 1208 return -EINVAL;
> 1209 }
> 1210
> 1211 u64_stats_add(&stats->bytes, len);
> 1212
> 1213 xdp = buf_to_xdp(vi, rq, buf, len);
> 1214 if (!xdp)
> 1215 goto err;
> 1216
> 1217 buf = napi_alloc_frag(len);
> 1218 if (!buf) {
> 1219 xsk_buff_free(xdp);
> 1220 goto err;
> 1221 }
> 1222
> 1223 memcpy(buf, xdp->data - vi->hdr_len, len);
> 1224
> 1225 xsk_buff_free(xdp);
> 1226
> > 1227 page = virt_to_page(buf);
> 1228
> 1229 truesize = len;
> 1230
> 1231 curr_skb = virtnet_skb_append_frag(head_skb, curr_skb, page,
> 1232 buf, len, truesize);
> 1233 if (!curr_skb) {
> 1234 put_page(page);
> 1235 goto err;
> 1236 }
> 1237 }
> 1238
> 1239 return 0;
> 1240
> 1241 err:
> 1242 xsk_drop_follow_bufs(vi->dev, rq, num_buf, stats);
> 1243 return -EINVAL;
> 1244 }
> 1245
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists