Re: Questionable code in pci_sal_read

Matthew Wilcox
2005-01-25T15:27:49Z

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