lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1261157824.2769.2.camel@achroite.uk.solarflarecom.com>
Date:	Fri, 18 Dec 2009 17:37:04 +0000
From:	Ben Hutchings <bhutchings@...arflare.com>
To:	Jeff Kirsher <jeffrey.t.kirsher@...el.com>
Cc:	netdev@...r.kernel.org, gospo@...hat.com,
	Mitch Williams <mitch.a.williams@...el.com>
Subject: Re: [RFC PATCH v2 2/6] net: Add netif_num_vf function

On Thu, 2009-12-17 at 17:34 -0800, Jeff Kirsher wrote:
> From: Williams, Mitch A <mitch.a.williams@...el.com>
> 
> Add a convenience function to determine how many VF devices are associated
> with a given PF network interface. If the device is not an SR-IOV physical
> function device, the function returns 0.
[...]
> +/**
> + *	netif_num_vf - return number of SR-IOV VFs
> + *	@dev: network device
> + *
> + *	Return the number of SR-IOV virtual function devices that are
> + *	associated with this physical function device. Returns 0 if
> + *	device is not a PF device, or if SR-IOV not enabled.
> + */
> +static inline int netif_num_vf(const struct net_device *dev)
> +{
> +	struct pci_dev *pdev;
> +	int retval = 0;
> +
> +	if (!dev)
> +		goto out;

Why should this function allow dev == NULL?

> +	if (!dev->dev.parent)
> +		goto out;
> +
> +	if (dev->dev.parent->bus == &pci_bus_type) {
> +		pdev = to_pci_dev(dev->dev.parent);
> +		retval = pci_num_vf(pdev);
> +	}
> +out:
> +	return retval;
[...]

It would be much clearer to write:

	struct pci_dev *pdev;

	if (dev && dev->dev.parent &&
	    dev->dev.parent->bus == &pci_bus_type) {
		pdev = to_pci_dev(dev->dev.parent);
		return pci_num_vf(pdev);
	} else {
		return 0;
	}

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

Powered by Openwall GNU/*/Linux Powered by OpenVZ