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: <20121129133650.GA30789@liondog.tnic>
Date:	Thu, 29 Nov 2012 14:36:50 +0100
From:	Borislav Petkov <bp@...en8.de>
To:	Daniel J Blueman <daniel@...ascale-asia.com>
Cc:	Ingo Molnar <mingo@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	H Peter Anvin <hpa@...or.com>,
	Steffen Persvold <sp@...ascale.com>, x86@...nel.org,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/4 v7] AMD64 EDAC: Fix PCI function lookup

On Tue, Nov 27, 2012 at 02:32:11PM +0800, Daniel J Blueman wrote:
> Fix locating sibling memory controller PCI functions by using the
> correct PCI domain.
> 
> v7: Refactor patches grouping changes
> 
> Signed-off-by: Daniel J Blueman <daniel@...ascale-asia.com>
> ---
>  drivers/edac/amd64_edac.c |   40 +++++++++++++++++++++-------------------
>  1 file changed, 21 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c
> index 60e93fa..62b7b17 100644
> --- a/drivers/edac/amd64_edac.c
> +++ b/drivers/edac/amd64_edac.c
> @@ -983,6 +983,24 @@ static u64 get_error_address(struct mce *m)
>  	return addr;
>  }
>  
> +static struct pci_dev *pci_get_related_function(unsigned int vendor,
> +						unsigned int device,
> +						struct pci_dev *related)
> +{
> +	struct pci_dev *dev = NULL;
> +
> +	dev = pci_get_device(vendor, device, dev);
> +	while (dev) {
> +		if (pci_domain_nr(dev->bus) == pci_domain_nr(related->bus) &&
> +		    (dev->bus->number == related->bus->number) &&
> +		    (PCI_SLOT(dev->devfn) == PCI_SLOT(related->devfn)))
> +			break;
> +		dev = pci_get_device(vendor, device, dev);
> +	}

This loop looks strange and I'm wondering, wouldn't it be more
straightforward to simply do:

	while (dev = pci_get_device(vendor, device, dev)) {
		if (...)
			break;
	}

	return dev;

I realize the original code does this pci_get_device twice but it is
crap IMO.

Thanks.

-- 
Regards/Gruss,
    Boris.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ