2007-08-14 03:37:35

by Scott Thompson

[permalink] [raw]
Subject: [PATCH ] /drivers/ata ioremap returncode check

patchset against 2.6.23-rc3. corrects missing ioremap return checks.

Warning -- cleanup handler here may miss additional required cleanup as has occurred on other
portions of ioremap audit.

This patch had been submitted previously but hushmail client caused wordwrap issues, resending
with different mail client.

Signed-off-by: Scott Thompson <postfail <at> hushmail.com>
----------------------------------------------------------

diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
index 4ca7fd6..eaebc4d 100644
--- a/drivers/ata/pata_ixp4xx_cf.c
+++ b/drivers/ata/pata_ixp4xx_cf.c
@@ -189,6 +189,14 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)
data->cs0 = devm_ioremap(&pdev->dev, cs0->start, 0x1000);
data->cs1 = devm_ioremap(&pdev->dev, cs1->start, 0x1000);

+ if (!data->cs0 || !data->cs1) {
+ if (data->cs0)
+ iounmap(data->cs0);
+ if (data->cs1)
+ iounmap(data->cs1);
+ return -ENOMEM;
+ }
+
irq = platform_get_irq(pdev, 0);
if (irq)
set_irq_type(irq, IRQT_RISING);



____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search
that gives answers, not web links.
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC


____________________________________________________________________________________
Luggage? GPS? Comic books?
Check out fitting gifts for grads at Yahoo! Search
http://search.yahoo.com/search?fr=oni_on_mail&p=graduation+gifts&cs=bz


2007-08-22 18:11:45

by Brandon Philips

[permalink] [raw]
Subject: Re: [PATCH ] /drivers/ata ioremap returncode check

On 20:31 Mon 13 Aug 2007, Scott Thompson wrote:
> patchset against 2.6.23-rc3. corrects missing ioremap return checks.
>
> Warning -- cleanup handler here may miss additional required cleanup as has occurred on other
> portions of ioremap audit.
>
> This patch had been submitted previously but hushmail client caused wordwrap issues, resending
> with different mail client.
>
> Signed-off-by: Scott Thompson <postfail <at> hushmail.com>
> ----------------------------------------------------------
>
> diff --git a/drivers/ata/pata_ixp4xx_cf.c b/drivers/ata/pata_ixp4xx_cf.c
> index 4ca7fd6..eaebc4d 100644
> --- a/drivers/ata/pata_ixp4xx_cf.c
> +++ b/drivers/ata/pata_ixp4xx_cf.c
> @@ -189,6 +189,14 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)
> data->cs0 = devm_ioremap(&pdev->dev, cs0->start, 0x1000);
> data->cs1 = devm_ioremap(&pdev->dev, cs1->start, 0x1000);
>
> + if (!data->cs0 || !data->cs1) {
> + if (data->cs0)
> + iounmap(data->cs0);
> + if (data->cs1)
> + iounmap(data->cs1);
> + return -ENOMEM;
> + }
> +
> irq = platform_get_irq(pdev, 0);
> if (irq)
> set_irq_type(irq, IRQT_RISING);

The iounmap calls are unnecessary since devm_ioremap will un-allocate
the space if you return an error from probe. See
Documentation/driver-model/devres.txt

But, something like this is needed.

+ if (!data->cs0 || !data->cs1)
+ return -ENOMEM;

Thanks,

Brandon