aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-mpc52xx.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-08-18 12:29:21 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-08-22 14:26:36 -0400
commit866c0f25d2dc896e647970cf5e371b5083a6e5d5 (patch)
treeb8d376d6b0c3602aeb16225c6d7f8e101bed4b23 /drivers/spi/spi-mpc52xx.c
parent495e3ff365425f9b69884ddde36047184f37c2bd (diff)
spi/mpc52xx: Fix error handling in probe function
The call to spi_master_put() is needed to free device memory. It must be called after spi_alloc_master, and must only be called after the device memory is no longer used. Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/spi/spi-mpc52xx.c')
-rw-r--r--drivers/spi/spi-mpc52xx.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c
index cb3a3830b0a5..a749589677be 100644
--- a/drivers/spi/spi-mpc52xx.c
+++ b/drivers/spi/spi-mpc52xx.c
@@ -454,7 +454,7 @@ static int __devinit mpc52xx_spi_probe(struct platform_device *op)
454 GFP_KERNEL); 454 GFP_KERNEL);
455 if (!ms->gpio_cs) { 455 if (!ms->gpio_cs) {
456 rc = -ENOMEM; 456 rc = -ENOMEM;
457 goto err_alloc; 457 goto err_alloc_gpio;
458 } 458 }
459 459
460 for (i = 0; i < ms->gpio_cs_count; i++) { 460 for (i = 0; i < ms->gpio_cs_count; i++) {
@@ -514,12 +514,13 @@ static int __devinit mpc52xx_spi_probe(struct platform_device *op)
514 514
515 err_register: 515 err_register:
516 dev_err(&ms->master->dev, "initialization failed\n"); 516 dev_err(&ms->master->dev, "initialization failed\n");
517 spi_master_put(master);
518 err_gpio: 517 err_gpio:
519 while (i-- > 0) 518 while (i-- > 0)
520 gpio_free(ms->gpio_cs[i]); 519 gpio_free(ms->gpio_cs[i]);
521 520
522 kfree(ms->gpio_cs); 521 kfree(ms->gpio_cs);
522 err_alloc_gpio:
523 spi_master_put(master);
523 err_alloc: 524 err_alloc:
524 err_init: 525 err_init:
525 iounmap(regs); 526 iounmap(regs);