[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1222365532.8641.86.camel@achroite>
Date: Thu, 25 Sep 2008 18:58:52 +0100
From: Ben Hutchings <bhutchings@...arflare.com>
To: Stephen Hemminger <shemminger@...tta.com>
Cc: Jeff Garzik <jgarzik@...ox.com>,
Jesse Barnes <jbarnes@...tuousgeek.org>,
netdev@...r.kernel.org, linux-pci@...r.kernel.org,
Ivan Vecera <ivecera@...hat.com>
Subject: Re: [PATCH 2/9] PCI: revise VPD access interface (rev3)
On Thu, 2008-09-25 at 09:48 -0700, Stephen Hemminger wrote:
[...]
> -static int pci_vpd_pci22_write(struct pci_dev *dev, int pos, int size,
> - const char *buf)
> +static ssize_t pci_vpd_pci22_write(struct pci_dev *dev, loff_t pos, size_t count,
> + const void *arg)
> {
> struct pci_vpd_pci22 *vpd =
> container_of(dev->vpd, struct pci_vpd_pci22, base);
> - u32 val;
> + const u8 *buf = arg;
> + loff_t end = pos + count;
count should be (count & ~3)
> int ret = 0;
>
> - if (pos < 0 || pos > vpd->base.len || pos & 3 ||
> - size > vpd->base.len - pos || size < 4)
> + if (pos > vpd->base.len || pos & 3)
> return -EINVAL;
Why did you remove the tests for pos < 0 and size > vpd->base.len - pos?
I know write_vpd_attr() checks these but you're about to add other
callers.
[...]
> out:
> mutex_unlock(&vpd->lock);
> - if (ret < 0)
> - return ret;
> -
> - return 4;
> + return ret ? ret : count;
> }
[...]
count should be (count & ~3)
Alternately you could treat (count & 3) != 0 as invalid.
Ben.
--
Ben Hutchings, Senior Software Engineer, Solarflare Communications
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists