public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: linux-kernel@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
	Dan Williams <dan.j.williams@intel.com>,
	Cornelia Huck <cohuck@redhat.com>
Subject: Re: [PATCH v1 5/5] vfio/pci: Drop duplicate check for size parameter of memremap()
Date: Fri, 15 Nov 2019 15:52:14 -0700	[thread overview]
Message-ID: <20191115155214.55e949cc@x1.home> (raw)
In-Reply-To: <20191115180044.83659-5-andriy.shevchenko@linux.intel.com>

On Fri, 15 Nov 2019 20:00:44 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Since memremap() returns NULL pointer for size = 0, there is no need
> to duplicate this check in the callers.
> 
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Cc: Alex Williamson <alex.williamson@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/vfio/pci/vfio_pci_igd.c | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_igd.c b/drivers/vfio/pci/vfio_pci_igd.c
> index 53d97f459252..3088a33af271 100644
> --- a/drivers/vfio/pci/vfio_pci_igd.c
> +++ b/drivers/vfio/pci/vfio_pci_igd.c
> @@ -75,13 +75,7 @@ static int vfio_pci_igd_opregion_init(struct vfio_pci_device *vdev)
>  		return -EINVAL;
>  	}
>  
> -	size = le32_to_cpu(*(__le32 *)(base + 16));
> -	if (!size) {
> -		memunmap(base);
> -		return -EINVAL;
> -	}
> -
> -	size *= 1024; /* In KB */
> +	size = le32_to_cpu(*(__le32 *)(base + 16)) * 1024; /* In KB */
>  
>  	if (size != OPREGION_SIZE) {
>  		memunmap(base);

This seems convoluted, patch 1/5 states "[t]here is no use of memremap()
to be called with size = 0", which we weren't doing thanks to the check
removed above.  So now we are potentially calling it with zero,
apparently only to take advantage of this new behavior, and we lose the
error granularity that previously such a condition failed with an
-EINVAL and now we fail with an -ENONMEM and cannot distinguish whether
the OpRegion table size was empty or we just weren't able to memremap()
it.  I don't see how this is an improvement.  Thanks,

Alex


  reply	other threads:[~2019-11-15 22:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15 18:00 [PATCH v1 1/5] memremap: Check for size parameter Andy Shevchenko
2019-11-15 18:00 ` [PATCH v1 2/5] dma-mapping: Drop duplicate check for size parameter of memremap() Andy Shevchenko
2019-11-16 16:29   ` Christoph Hellwig
2019-11-15 18:00 ` [PATCH v1 3/5] ALSA: hda: " Andy Shevchenko
2019-11-15 18:00 ` [PATCH v1 4/5] efi/esrt: " Andy Shevchenko
2019-11-15 18:00 ` [PATCH v1 5/5] vfio/pci: " Andy Shevchenko
2019-11-15 22:52   ` Alex Williamson [this message]
2019-11-16 16:29 ` [PATCH v1 1/5] memremap: Check for size parameter Christoph Hellwig
2020-04-15 14:58   ` Andy Shevchenko

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=20191115155214.55e949cc@x1.home \
    --to=alex.williamson@redhat.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=cohuck@redhat.com \
    --cc=dan.j.williams@intel.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@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