Re: Questionable code in pci_sal_read

From: Matthew Wilcox <matthew_at_wil.cx>
Date: 2005-01-26 02:27:49
On Tue, Jan 25, 2005 at 04:21:45PM +0100, Andreas Schwab wrote:
> These are the first few lines in pci_sal_read:
> 
> 	if ((seg > 255) || (bus > 255) || (devfn > 255) || (reg > 4095))
> 		return -EINVAL;

This line is incorrect, the check should be against (seg > 65535).
Good catch.

> 	if ((seg | reg) <= 255) {
> 
> When seg <= 255 then ((seg | reg) <= 255) is equivalent to (reg <= 255).
> But pci_sal_write only rejects (seg > 65535).
> 
> The lines come from this changeset:
> 
> http://linux.bkbits.net:8080/linux-2.6/cset%40407c8325V8ZAIQkFDRCUNpu5AXqG1g
> 
> Andreas.
> 
> -- 
> Andreas Schwab, SuSE Labs, schwab@suse.de
> SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
> Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> "And now for something completely different."
> -
> To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain
-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Tue Jan 25 10:28:53 2005

This archive was generated by hypermail 2.1.8 : 2005-08-02 09:20:35 EST