i2c-omap: Fix NULL pointer dereferencing
authorTony Lindgren <tony@atomide.com>
Mon, 14 Jan 2008 20:53:30 +0000 (21:53 +0100)
committerJean Delvare <khali@hyperion.delvare>
Mon, 14 Jan 2008 20:53:30 +0000 (21:53 +0100)
This patch fixes bug #9581 reported by Marcio Buss. If kzalloc fails,
omap_i2c_write_reg() tries to reset an unallocated I2C controller.

Cc: Marcio Buss <marciobuss@gmail.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
drivers/i2c/busses/i2c-omap.c

index cb55cf2ba1e91a4279f3406f34216b4a59f4094e..f2552b19ea607d741082ca54aec28c4984b614f8 100644 (file)
@@ -619,13 +619,13 @@ omap_i2c_probe(struct platform_device *pdev)
 err_free_irq:
        free_irq(dev->irq, dev);
 err_unuse_clocks:
+       omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
        omap_i2c_disable_clocks(dev);
        omap_i2c_put_clocks(dev);
 err_free_mem:
        platform_set_drvdata(pdev, NULL);
        kfree(dev);
 err_release_region:
-       omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0);
        release_mem_region(mem->start, (mem->end - mem->start) + 1);
 
        return r;