Skip to content

Commit

Permalink
pata_at91: fix resource release
Browse files Browse the repository at this point in the history
Julias Lawall discovered that pata_at91 wasn't freeing a memory region
allocated with kzalloc() on init failure paths.  Upon review,
pata_at91 also seems to be doing unnecessary explicit resource
releases for managed resources too.  Convert memory allocation to
managed one and drop unnecessary explicit resource releases.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Julia Lawall <julia@diku.dk>
Cc: Sergey Matyukevich <geomatsi@gmail.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
  • Loading branch information
Tejun Heo authored and Jeff Garzik committed Aug 12, 2009
1 parent 7cb7beb commit df9eba8
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions drivers/ata/pata_at91.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static int __devinit pata_at91_probe(struct platform_device *pdev)
ata_port_desc(ap, "no IRQ, using PIO polling");
}

info = kzalloc(sizeof(*info), GFP_KERNEL);
info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);

if (!info) {
dev_err(dev, "failed to allocate memory for private data\n");
Expand All @@ -275,7 +275,7 @@ static int __devinit pata_at91_probe(struct platform_device *pdev)
if (!info->ide_addr) {
dev_err(dev, "failed to map IO base\n");
ret = -ENOMEM;
goto err_ide_ioremap;
goto err_put;
}

info->alt_addr = devm_ioremap(dev,
Expand All @@ -284,7 +284,7 @@ static int __devinit pata_at91_probe(struct platform_device *pdev)
if (!info->alt_addr) {
dev_err(dev, "failed to map CTL base\n");
ret = -ENOMEM;
goto err_alt_ioremap;
goto err_put;
}

ap->ioaddr.cmd_addr = info->ide_addr;
Expand All @@ -303,21 +303,15 @@ static int __devinit pata_at91_probe(struct platform_device *pdev)
irq ? ata_sff_interrupt : NULL,
irq_flags, &pata_at91_sht);

err_alt_ioremap:
devm_iounmap(dev, info->ide_addr);

err_ide_ioremap:
err_put:
clk_put(info->mck);
kfree(info);

return ret;
}

static int __devexit pata_at91_remove(struct platform_device *pdev)
{
struct ata_host *host = dev_get_drvdata(&pdev->dev);
struct at91_ide_info *info;
struct device *dev = &pdev->dev;

if (!host)
return 0;
Expand All @@ -328,11 +322,8 @@ static int __devexit pata_at91_remove(struct platform_device *pdev)
if (!info)
return 0;

devm_iounmap(dev, info->ide_addr);
devm_iounmap(dev, info->alt_addr);
clk_put(info->mck);

kfree(info);
return 0;
}

Expand Down

0 comments on commit df9eba8

Please sign in to comment.