[Patch 2/2] powerpc: i2c-isa: add access check to legacy ioports

Jean Delvare khali at linux-fr.org
Tue Feb 19 00:31:39 EST 2008


Hi Christian,

On Wed, 13 Feb 2008 18:37:01 +0100, Christian Krafft wrote:
> when probing i2c-pca-isa writes to legacy ioports, which crashes the kernel
> if there is no device at that port.
> This patch adds a check_legacy_ioport call, so probe failes gracefully
> and thus prevents the oops.
> 
> Signed-off-by: Christian Krafft <krafft at de.ibm.com>
> 
> Index: linux.git/drivers/i2c/busses/i2c-pca-isa.c
> ===================================================================
> --- linux.git.orig/drivers/i2c/busses/i2c-pca-isa.c
> +++ linux.git/drivers/i2c/busses/i2c-pca-isa.c
> @@ -125,6 +125,13 @@ static int __devinit pca_isa_probe(struc
>  
>  	dev_info(dev, "i/o base %#08lx. irq %d\n", base, irq);
>  
> +#ifdef CONFIG_PPC_MERGE
> +	if (check_legacy_ioport(base)) {
> +		dev_err(dev, "I/O address %#08lx is not available\n", base);
> +		goto out;
> +	}
> +#endif
> +
>  	if (!request_region(base, IO_SIZE, "i2c-pca-isa")) {
>  		dev_err(dev, "I/O address %#08lx is in use\n", base);
>  		goto out;
> 

I can apply this, no problem. That being said, you might alternatively
just exclude this driver from PPC. It's for a rare device with no known
user, the driver is unmaintained and will hopefully be replaced soon by
a platform driver which will not probe random ports at load time.

-- 
Jean Delvare



More information about the Linuxppc-dev mailing list