public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Eli Cohen <eli@mellanox.com>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org,
	"Michael S. Tsirkin" <mst@redhat.com>,
	Parav Pandit <parav@mellanox.com>
Subject: [kbuild] drivers/vdpa/mlx5/core/mr.c:282 map_direct_mr() warn: missing error code 'err'
Date: Fri, 9 Apr 2021 11:52:40 +0300	[thread overview]
Message-ID: <20210409085239.GF6048@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 5796 bytes --]

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 <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

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  229  	struct vhost_iotlb_map *map;
94abbccdf2916c Eli Cohen 2020-08-04  230  	unsigned long lgcd = 0;
94abbccdf2916c Eli Cohen 2020-08-04  231  	int log_entity_size;
94abbccdf2916c Eli Cohen 2020-08-04  232  	unsigned long size;
94abbccdf2916c Eli Cohen 2020-08-04  233  	u64 start = 0;
94abbccdf2916c Eli Cohen 2020-08-04  234  	int err;
94abbccdf2916c Eli Cohen 2020-08-04  235  	struct page *pg;
94abbccdf2916c Eli Cohen 2020-08-04  236  	unsigned int nsg;
94abbccdf2916c Eli Cohen 2020-08-04  237  	int sglen;
94abbccdf2916c Eli Cohen 2020-08-04  238  	u64 pa;
94abbccdf2916c Eli Cohen 2020-08-04  239  	u64 paend;
94abbccdf2916c Eli Cohen 2020-08-04  240  	struct scatterlist *sg;
94abbccdf2916c Eli Cohen 2020-08-04  241  	struct device *dma = mvdev->mdev->device;
94abbccdf2916c Eli Cohen 2020-08-04  242  	int ret;
94abbccdf2916c Eli Cohen 2020-08-04  243  
94abbccdf2916c Eli Cohen 2020-08-04  244  	for (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  246  		size = maplen(map, mr);
94abbccdf2916c Eli Cohen 2020-08-04  247  		lgcd = gcd(lgcd, size);
94abbccdf2916c Eli Cohen 2020-08-04  248  		start += size;
94abbccdf2916c Eli Cohen 2020-08-04  249  	}
94abbccdf2916c Eli Cohen 2020-08-04  250  	log_entity_size = ilog2(lgcd);
94abbccdf2916c Eli Cohen 2020-08-04  251  
94abbccdf2916c Eli Cohen 2020-08-04  252  	sglen = 1 << log_entity_size;
94abbccdf2916c Eli Cohen 2020-08-04  253  	nsg = 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  255  	err = sg_alloc_table(&mr->sg_head, nsg, GFP_KERNEL);
94abbccdf2916c Eli Cohen 2020-08-04  256  	if (err)
94abbccdf2916c Eli Cohen 2020-08-04  257  		return err;
94abbccdf2916c Eli Cohen 2020-08-04  258  
94abbccdf2916c Eli Cohen 2020-08-04  259  	sg = mr->sg_head.sgl;
94abbccdf2916c Eli Cohen 2020-08-04  260  	for (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  262  		paend = map->addr + maplen(map, mr);
94abbccdf2916c Eli Cohen 2020-08-04  263  		for (pa = map->addr; pa < paend; pa += sglen) {
94abbccdf2916c Eli Cohen 2020-08-04  264  			pg = pfn_to_page(__phys_to_pfn(pa));
94abbccdf2916c Eli Cohen 2020-08-04  265  			if (!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  268  				err = -ENOMEM;
94abbccdf2916c Eli Cohen 2020-08-04  269  				goto err_map;
94abbccdf2916c Eli Cohen 2020-08-04  270  			}
94abbccdf2916c Eli Cohen 2020-08-04  271  			sg_set_page(sg, pg, sglen, 0);
94abbccdf2916c Eli Cohen 2020-08-04  272  			sg = sg_next(sg);
94abbccdf2916c Eli Cohen 2020-08-04  273  			if (!sg)
94abbccdf2916c Eli Cohen 2020-08-04  274  				goto 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  278  	mr->log_size = log_entity_size;
94abbccdf2916c Eli Cohen 2020-08-04  279  	mr->nsg = nsg;
94abbccdf2916c Eli Cohen 2020-08-04  280  	ret = dma_map_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0);
94abbccdf2916c Eli Cohen 2020-08-04  281  	if (!ret)
94abbccdf2916c Eli Cohen 2020-08-04 @282  		goto err_map;
                                                        ^^^^^^^^^^^^^
This feels deliberate but it's an error path so that's sort of
confusing...  Not sure.

94abbccdf2916c Eli Cohen 2020-08-04  283  
94abbccdf2916c Eli Cohen 2020-08-04  284  	err = create_direct_mr(mvdev, mr);
94abbccdf2916c Eli Cohen 2020-08-04  285  	if (err)
94abbccdf2916c Eli Cohen 2020-08-04  286  		goto err_direct;
94abbccdf2916c Eli Cohen 2020-08-04  287  
94abbccdf2916c Eli Cohen 2020-08-04  288  	return 0;
94abbccdf2916c Eli Cohen 2020-08-04  289  
94abbccdf2916c Eli Cohen 2020-08-04  290  err_direct:
94abbccdf2916c Eli Cohen 2020-08-04  291  	dma_unmap_sg_attrs(dma, mr->sg_head.sgl, mr->nsg, DMA_BIDIRECTIONAL, 0);
94abbccdf2916c Eli Cohen 2020-08-04  292  err_map:
94abbccdf2916c Eli Cohen 2020-08-04  293  	sg_free_table(&mr->sg_head);
94abbccdf2916c Eli Cohen 2020-08-04  294  	return err;
94abbccdf2916c Eli Cohen 2020-08-04  295  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org 

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 27486 bytes --]

[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org

                 reply	other threads:[~2021-04-09  8:52 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=20210409085239.GF6048@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=eli@mellanox.com \
    --cc=kbuild-all@lists.01.org \
    --cc=kbuild@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=mst@redhat.com \
    --cc=parav@mellanox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox