[kbuild] drivers/vdpa/mlx5/core/mr.c:282 map_direct_mr() warn: missing error code 'err'
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: e49d033bddf5b565044e2abe4241353959bc9120 commit: 94abbccdf2916cb03f9626f2d36c6e9971490c12 vdpa/mlx5: Add shared memory registration code config: microblaze-randconfig-m031-20210405 (attached as .config) compiler: microblaze-linux-gcc (GCC) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot Reported-by: Dan Carpenter New smatch warnings: drivers/vdpa/mlx5/core/mr.c:282 map_direct_mr() warn: missing error code 'err' Old smatch warnings: drivers/vdpa/mlx5/core/mr.c:350 add_direct_chain() error: uninitialized symbol 'err'. drivers/vdpa/mlx5/core/mr.c:483 mlx5_vdpa_handle_set_map() error: uninitialized symbol 'err'. vim +/err +282 drivers/vdpa/mlx5/core/mr.c 94abbccdf2916c Eli Cohen 2020-08-04 226 static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr, 94abbccdf2916c Eli Cohen 2020-08-04 227 struct vhost_iotlb *iotlb) 94abbccdf2916c Eli Cohen 2020-08-04 228 { 94abbccdf2916c Eli Cohen 2020-08-04 229struct vhost_iotlb_map *map; 94abbccdf2916c Eli Cohen 2020-08-04 230unsigned long lgcd = 0; 94abbccdf2916c Eli Cohen 2020-08-04 231int log_entity_size; 94abbccdf2916c Eli Cohen 2020-08-04 232unsigned long size; 94abbccdf2916c Eli Cohen 2020-08-04 233u64 start = 0; 94abbccdf2916c Eli Cohen 2020-08-04 234int err; 94abbccdf2916c Eli Cohen 2020-08-04 235struct page *pg; 94abbccdf2916c Eli Cohen 2020-08-04 236unsigned int nsg; 94abbccdf2916c Eli Cohen 2020-08-04 237int sglen; 94abbccdf2916c Eli Cohen 2020-08-04 238u64 pa; 94abbccdf2916c Eli Cohen 2020-08-04 239u64 paend; 94abbccdf2916c Eli Cohen 2020-08-04 240struct scatterlist *sg; 94abbccdf2916c Eli Cohen 2020-08-04 241struct device *dma = mvdev->mdev->device; 94abbccdf2916c Eli Cohen 2020-08-04 242int ret; 94abbccdf2916c Eli Cohen 2020-08-04 243 94abbccdf2916c Eli Cohen 2020-08-04 244for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1); 94abbccdf2916c Eli Cohen 2020-08-04 245 map; map = vhost_iotlb_itree_next(map, start, mr->end - 1)) { 94abbccdf2916c Eli Cohen 2020-08-04 246size = maplen(map, mr); 94abbccdf2916c Eli Cohen 2020-08-04 247lgcd = gcd(lgcd, size); 94abbccdf2916c Eli Cohen 2020-08-04 248start += size; 94abbccdf2916c Eli Cohen 2020-08-04 249} 94abbccdf2916c Eli Cohen 2020-08-04 250log_entity_size = ilog2(lgcd); 94abbccdf2916c Eli Cohen 2020-08-04 251 94abbccdf2916c Eli Cohen 2020-08-04 252sglen = 1 << log_entity_size; 94abbccdf2916c Eli Cohen 2020-08-04 253nsg = MLX5_DIV_ROUND_UP_POW2(mr->end - mr->start, log_entity_size); 94abbccdf2916c Eli Cohen 2020-08-04 254 94abbccdf2916c Eli Cohen 2020-08-04 255err = sg_alloc_table(>sg_head, nsg, GFP_KERNEL); 94abbccdf2916c Eli Cohen 2020-08-04 256if (err) 94abbccdf2916c Eli Cohen 2020-08-04 257return err; 94abbccdf2916c Eli Cohen 2020-08-04 258 94abbccdf2916c Eli Cohen 2020-08-04 259sg = mr->sg_head.sgl; 94abbccdf2916c Eli Cohen 2020-08-04 260for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1); 94abbccdf2916c Eli Cohen 2020-08-04 261 map; map = vhost_iotlb_itree_next(map, mr->start, mr->end - 1)) { 94abbccdf2916c Eli Cohen 2020-08-04 262paend = map->addr + maplen(map, mr); 94abbccdf2916c Eli Cohen 2020-08-04 263for (pa = map->addr; pa < paend; pa += sglen) { 94abbccdf2916c Eli Cohen 2020-08-04 264pg = pfn_to_page(__phys_to_pfn(pa)); 94abbccdf2916c Eli Cohen 2020-08-04 265if (!sg) { 94abbccdf2916c Eli Cohen 2020-08-04 266 mlx5_vdpa_warn(mvdev, "sg null. start 0x%llx, end 0x%llx\n", 94abbccdf2916c Eli Cohen 2020-08-04 267 map->start, map->last + 1); 94abbccdf2916c Eli Cohen 2020-08-04 268err = -ENOMEM; 94abbccdf2916c Eli Cohen 2020-08-04 269goto err_map; 94abbccdf2916c Eli Cohen 2020-08-04 270} 94abbccdf2916c Eli Cohen 2020-08-04 271sg_set_page(sg, pg, sglen, 0); 94abbccdf2916c Eli Cohen 2020-08-04 272sg = sg_next(sg); 94abbccdf2916c Eli Cohen 2020-08-04 273if (!sg) 94abbccdf2916c Eli Cohen 2020-08-04 274goto done; 94abbccdf2916c Eli Cohen 2020-08-04 275} 94abbccdf2916c Eli Cohen 2020-08-04 276} 94abbccdf2916c Eli Cohen 2020-08-04 277 done: 94abbccdf2916c Eli Cohen 2020-08-04 278mr->log_size = log_entity_size; 94abbccdf2916c Eli Cohen 2020-08-04 279mr->nsg = nsg;
[kbuild] drivers/vdpa/mlx5/core/mr.c:282 map_direct_mr() warn: missing error code 'err'
CC: kbuild-...@lists.01.org CC: linux-ker...@vger.kernel.org TO: Eli Cohen CC: "Michael S. Tsirkin" CC: Parav Pandit tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: e49d033bddf5b565044e2abe4241353959bc9120 commit: 94abbccdf2916cb03f9626f2d36c6e9971490c12 vdpa/mlx5: Add shared memory registration code date: 8 months ago :: branch date: 16 hours ago :: commit date: 8 months ago config: microblaze-randconfig-m031-20210405 (attached as .config) compiler: microblaze-linux-gcc (GCC) 9.3.0 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot Reported-by: Dan Carpenter New smatch warnings: drivers/vdpa/mlx5/core/mr.c:282 map_direct_mr() warn: missing error code 'err' Old smatch warnings: drivers/vdpa/mlx5/core/mr.c:350 add_direct_chain() error: uninitialized symbol 'err'. drivers/vdpa/mlx5/core/mr.c:483 mlx5_vdpa_handle_set_map() error: uninitialized symbol 'err'. vim +/err +282 drivers/vdpa/mlx5/core/mr.c 94abbccdf2916c Eli Cohen 2020-08-04 225 94abbccdf2916c Eli Cohen 2020-08-04 226 static int map_direct_mr(struct mlx5_vdpa_dev *mvdev, struct mlx5_vdpa_direct_mr *mr, 94abbccdf2916c Eli Cohen 2020-08-04 227 struct vhost_iotlb *iotlb) 94abbccdf2916c Eli Cohen 2020-08-04 228 { 94abbccdf2916c Eli Cohen 2020-08-04 229struct vhost_iotlb_map *map; 94abbccdf2916c Eli Cohen 2020-08-04 230unsigned long lgcd = 0; 94abbccdf2916c Eli Cohen 2020-08-04 231int log_entity_size; 94abbccdf2916c Eli Cohen 2020-08-04 232unsigned long size; 94abbccdf2916c Eli Cohen 2020-08-04 233u64 start = 0; 94abbccdf2916c Eli Cohen 2020-08-04 234int err; 94abbccdf2916c Eli Cohen 2020-08-04 235struct page *pg; 94abbccdf2916c Eli Cohen 2020-08-04 236unsigned int nsg; 94abbccdf2916c Eli Cohen 2020-08-04 237int sglen; 94abbccdf2916c Eli Cohen 2020-08-04 238u64 pa; 94abbccdf2916c Eli Cohen 2020-08-04 239u64 paend; 94abbccdf2916c Eli Cohen 2020-08-04 240struct scatterlist *sg; 94abbccdf2916c Eli Cohen 2020-08-04 241struct device *dma = mvdev->mdev->device; 94abbccdf2916c Eli Cohen 2020-08-04 242int ret; 94abbccdf2916c Eli Cohen 2020-08-04 243 94abbccdf2916c Eli Cohen 2020-08-04 244for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1); 94abbccdf2916c Eli Cohen 2020-08-04 245 map; map = vhost_iotlb_itree_next(map, start, mr->end - 1)) { 94abbccdf2916c Eli Cohen 2020-08-04 246size = maplen(map, mr); 94abbccdf2916c Eli Cohen 2020-08-04 247lgcd = gcd(lgcd, size); 94abbccdf2916c Eli Cohen 2020-08-04 248start += size; 94abbccdf2916c Eli Cohen 2020-08-04 249} 94abbccdf2916c Eli Cohen 2020-08-04 250log_entity_size = ilog2(lgcd); 94abbccdf2916c Eli Cohen 2020-08-04 251 94abbccdf2916c Eli Cohen 2020-08-04 252sglen = 1 << log_entity_size; 94abbccdf2916c Eli Cohen 2020-08-04 253nsg = MLX5_DIV_ROUND_UP_POW2(mr->end - mr->start, log_entity_size); 94abbccdf2916c Eli Cohen 2020-08-04 254 94abbccdf2916c Eli Cohen 2020-08-04 255err = sg_alloc_table(>sg_head, nsg, GFP_KERNEL); 94abbccdf2916c Eli Cohen 2020-08-04 256if (err) 94abbccdf2916c Eli Cohen 2020-08-04 257return err; 94abbccdf2916c Eli Cohen 2020-08-04 258 94abbccdf2916c Eli Cohen 2020-08-04 259sg = mr->sg_head.sgl; 94abbccdf2916c Eli Cohen 2020-08-04 260for (map = vhost_iotlb_itree_first(iotlb, mr->start, mr->end - 1); 94abbccdf2916c Eli Cohen 2020-08-04 261 map; map = vhost_iotlb_itree_next(map, mr->start, mr->end - 1)) { 94abbccdf2916c Eli Cohen 2020-08-04 262paend = map->addr + maplen(map, mr); 94abbccdf2916c Eli Cohen 2020-08-04 263for (pa = map->addr; pa < paend; pa += sglen) { 94abbccdf2916c Eli Cohen 2020-08-04 264pg = pfn_to_page(__phys_to_pfn(pa)); 94abbccdf2916c Eli Cohen 2020-08-04 265if (!sg) { 94abbccdf2916c Eli Cohen 2020-08-04 266 mlx5_vdpa_warn(mvdev, "sg null. start 0x%llx, end 0x%llx\n", 94abbccdf2916c Eli Cohen 2020-08-04 267 map->start, map->last + 1); 94abbccdf2916c Eli Cohen 2020-08-04 268err = -ENOMEM; 94abbccdf2916c Eli Cohen 2020-08-04 269goto err_map; 94abbccdf2916c Eli Cohen 2020-08-04 270} 94abbccdf2916c Eli Cohen 2020-08-04 271sg_set_page(sg, pg, sglen, 0); 94abbccdf2916c Eli Cohen 2020-08-04 272sg = sg_next(sg); 94abbccdf2916c Eli Cohen 2020-08-04 273if (!sg) 94abbccdf2916c Eli Cohen 2020-08-04 274goto done; 94abbccdf2916c Eli Cohen 2020-08-04 275