public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Fengguang Wu <fengguang.wu@intel.com>
Cc: Alex Williamson <alex.williamson@redhat.com>, kvm@vger.kernel.org
Subject: Re: [kbuild] [vfio:vfio-vga 4/5] drivers/vfio/pci/vfio_pci_rdwr.c:191 vfio_pci_legacy_mem_rw() warn: consider using resource_size() here
Date: Mon, 21 Jan 2013 21:17:51 +0300	[thread overview]
Message-ID: <20130121181751.GY16282@mwanda> (raw)
In-Reply-To: <20130117012049.GA7017@localhost>

Hi Fengguang,

I already forwarded these on Thursday.  You should have got a mail
about it because I CC'd the kbuild list.

regards,
dan carpenter

On Thu, Jan 17, 2013 at 09:20:49AM +0800, Fengguang Wu wrote:
> 
> Hi Alex,
> 
> FYI, there are new smatch warnings show up in
> 
> tree:   git://github.com/awilliam/linux-vfio.git vfio-vga
> head:   2c2e21fa66c40ed7b8e434c86a9f2ab0c879f21d
> commit: c5b7a5a85fa477e70497c513f2acda50eea73bf7 [4/5] vfio-pci: Add support for legacy MMIO & I/O port towards VGA support
> 
> New smatch warnings:
> drivers/vfio/pci/vfio_pci_rdwr.c:191 vfio_pci_legacy_mem_rw() warn: consider using resource_size() here
> drivers/vfio/pci/vfio_pci_rdwr.c:206 vfio_pci_legacy_mem_rw() warn: always true condition '(done >= 0) => (0-u32max >= 0)'
> drivers/vfio/pci/vfio_pci_rdwr.c:254 vfio_pci_legacy_io_rw() warn: always true condition '(done >= 0) => (0-u32max >= 0)'
> 
> Old smatch warnings:
> drivers/vfio/pci/vfio_pci_rdwr.c:170 vfio_pci_bar_rw() warn: always true condition '(done >= 0) => (0-u32max >= 0)'
> 
> vim +191 drivers/vfio/pci/vfio_pci_rdwr.c
> 
> c5b7a5a8 Alex Williamson 2013-01-16  185  	if (vdev->has_vga && pos >= 0xa0000 && pos < 0xc0000) {
> c5b7a5a8 Alex Williamson 2013-01-16  186  		void __iomem *mem;
> c5b7a5a8 Alex Williamson 2013-01-16  187  		size_t done;
> c5b7a5a8 Alex Williamson 2013-01-16  188  
> c5b7a5a8 Alex Williamson 2013-01-16  189  		count = min(count, (size_t)(0xc0000 - pos));
> c5b7a5a8 Alex Williamson 2013-01-16  190  
> c5b7a5a8 Alex Williamson 2013-01-16 @191  		mem = ioremap_nocache(0xa0000, 0xc0000 - 0xa0000);
> c5b7a5a8 Alex Williamson 2013-01-16  192  		if (!mem)
> c5b7a5a8 Alex Williamson 2013-01-16  193  			return -ENOMEM;
> c5b7a5a8 Alex Williamson 2013-01-16  194  
> c5b7a5a8 Alex Williamson 2013-01-16  195  		ret = vga_get_interruptible(vdev->pdev, VGA_RSRC_LEGACY_MEM);
> c5b7a5a8 Alex Williamson 2013-01-16  196  		if (ret) {
> c5b7a5a8 Alex Williamson 2013-01-16  197  			iounmap(mem);
> c5b7a5a8 Alex Williamson 2013-01-16  198  			return ret;
> c5b7a5a8 Alex Williamson 2013-01-16  199  		}
> c5b7a5a8 Alex Williamson 2013-01-16  200  
> c5b7a5a8 Alex Williamson 2013-01-16  201  		done = do_io_rw(mem, buf, pos - 0xa0000, count, 0, 0, iswrite);
> c5b7a5a8 Alex Williamson 2013-01-16  202  
> c5b7a5a8 Alex Williamson 2013-01-16  203  		vga_put(vdev->pdev, VGA_RSRC_LEGACY_MEM);
> c5b7a5a8 Alex Williamson 2013-01-16  204  		iounmap(mem);
> c5b7a5a8 Alex Williamson 2013-01-16  205  
> c5b7a5a8 Alex Williamson 2013-01-16 @206  		if (done >= 0)
> c5b7a5a8 Alex Williamson 2013-01-16  207  			*ppos += done;
> c5b7a5a8 Alex Williamson 2013-01-16  208  
> c5b7a5a8 Alex Williamson 2013-01-16  209  		return done;
> c5b7a5a8 Alex Williamson 2013-01-16  210  	}
> c5b7a5a8 Alex Williamson 2013-01-16  211  
> c5b7a5a8 Alex Williamson 2013-01-16  212  	return -EINVAL;
> c5b7a5a8 Alex Williamson 2013-01-16  213  }
> c5b7a5a8 Alex Williamson 2013-01-16  214  
> c5b7a5a8 Alex Williamson 2013-01-16  215  ssize_t vfio_pci_legacy_io_rw(struct vfio_pci_device *vdev, char __user *buf,
> c5b7a5a8 Alex Williamson 2013-01-16  216  			      size_t count, loff_t *ppos, bool iswrite)
> c5b7a5a8 Alex Williamson 2013-01-16  217  {
> c5b7a5a8 Alex Williamson 2013-01-16  218  	int ret;
> c5b7a5a8 Alex Williamson 2013-01-16  219  	loff_t pos = *ppos & VFIO_PCI_OFFSET_MASK;
> c5b7a5a8 Alex Williamson 2013-01-16  220  
> c5b7a5a8 Alex Williamson 2013-01-16  221  	if (vdev->has_vga &&
> c5b7a5a8 Alex Williamson 2013-01-16  222  	    ((pos >= 0x3b0 && pos < 0x3bc) || (pos >= 0x3c0 && pos < 0x3e0))) {
> c5b7a5a8 Alex Williamson 2013-01-16  223  		void __iomem *io = NULL;
> c5b7a5a8 Alex Williamson 2013-01-16  224  		loff_t off;
> c5b7a5a8 Alex Williamson 2013-01-16  225  		size_t done;
> c5b7a5a8 Alex Williamson 2013-01-16  226  
> c5b7a5a8 Alex Williamson 2013-01-16  227  		switch (pos) {
> c5b7a5a8 Alex Williamson 2013-01-16  228  		case 0x3b0 ... 0x3bb:
> c5b7a5a8 Alex Williamson 2013-01-16  229  			count = min(count, (size_t)(0x3bc - pos));
> c5b7a5a8 Alex Williamson 2013-01-16  230  			io = ioport_map(0x3b0, 0x3bc - 0x3b0);
> c5b7a5a8 Alex Williamson 2013-01-16  231  			off = pos - 0x3b0;
> c5b7a5a8 Alex Williamson 2013-01-16  232  			break;
> c5b7a5a8 Alex Williamson 2013-01-16  233  		case 0x3c0 ... 0x3df:
> c5b7a5a8 Alex Williamson 2013-01-16  234  			count = min(count, (size_t)(0x3e0 - pos));
> c5b7a5a8 Alex Williamson 2013-01-16  235  			io = ioport_map(0x3c0, 0x3e0 - 0x3c0);
> c5b7a5a8 Alex Williamson 2013-01-16  236  			off = pos - 0x3c0;
> c5b7a5a8 Alex Williamson 2013-01-16  237  			break;
> c5b7a5a8 Alex Williamson 2013-01-16  238  		}
> c5b7a5a8 Alex Williamson 2013-01-16  239  
> c5b7a5a8 Alex Williamson 2013-01-16  240  		if (!io)
> c5b7a5a8 Alex Williamson 2013-01-16  241  			return -ENOMEM;
> c5b7a5a8 Alex Williamson 2013-01-16  242  
> c5b7a5a8 Alex Williamson 2013-01-16  243  		ret = vga_get_interruptible(vdev->pdev, VGA_RSRC_LEGACY_IO);
> c5b7a5a8 Alex Williamson 2013-01-16  244  		if (ret) {
> c5b7a5a8 Alex Williamson 2013-01-16  245  			ioport_unmap(io);
> c5b7a5a8 Alex Williamson 2013-01-16  246  			return ret;
> c5b7a5a8 Alex Williamson 2013-01-16  247  		}
> c5b7a5a8 Alex Williamson 2013-01-16  248  
> c5b7a5a8 Alex Williamson 2013-01-16  249  		done = do_io_rw(io, buf, off, count, 0, 0, iswrite);
> c5b7a5a8 Alex Williamson 2013-01-16  250  
> c5b7a5a8 Alex Williamson 2013-01-16  251  		vga_put(vdev->pdev, VGA_RSRC_LEGACY_IO);
> c5b7a5a8 Alex Williamson 2013-01-16  252  		ioport_unmap(io);
> c5b7a5a8 Alex Williamson 2013-01-16  253  
> c5b7a5a8 Alex Williamson 2013-01-16 @254  		if (done >= 0)
> c5b7a5a8 Alex Williamson 2013-01-16  255  			*ppos += done;
> c5b7a5a8 Alex Williamson 2013-01-16  256  
> c5b7a5a8 Alex Williamson 2013-01-16  257  		return done;
> 
> ---
> 0-DAY kernel build testing backend              Open Source Technology Center
> http://lists.01.org/mailman/listinfo/kbuild                 Intel Corporation
> _______________________________________________
> kbuild mailing list
> kbuild@lists.01.org
> https://lists.01.org/mailman/listinfo/kbuild
> _______________________________________________
> kbuild mailing list
> kbuild@lists.01.org
> https://lists.01.org/mailman/listinfo/kbuild

  reply	other threads:[~2013-01-21 18:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <50f710b7.bKAbZBXVqYjysXq+%fengguang.wu@intel.com>
2013-01-17  1:20 ` [kbuild] [vfio:vfio-vga 4/5] drivers/vfio/pci/vfio_pci_rdwr.c:191 vfio_pci_legacy_mem_rw() warn: consider using resource_size() here Fengguang Wu
2013-01-21 18:17   ` Dan Carpenter [this message]
2013-01-22  0:59     ` Fengguang Wu

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=20130121181751.GY16282@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=alex.williamson@redhat.com \
    --cc=fengguang.wu@intel.com \
    --cc=kvm@vger.kernel.org \
    /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