mfd: ab8500-core improved error handling in get_chip_id
authorMattias Wallin <mattias.wallin@stericsson.com>
Thu, 2 Dec 2010 14:08:32 +0000 (15:08 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Fri, 14 Jan 2011 11:37:46 +0000 (12:37 +0100)
We check for dev before dereferencing it.

Signed-off-by: Mattias Wallin <mattias.wallin@stericsson.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/mfd/ab8500-core.c

index d9640a6..e91b5b7 100644 (file)
@@ -103,8 +103,12 @@ static const int ab8500_irq_regoffset[AB8500_NUM_IRQ_REGS] = {
 
 static int ab8500_get_chip_id(struct device *dev)
 {
-       struct ab8500 *ab8500 = dev_get_drvdata(dev->parent);
-       return (int)ab8500->chip_id;
+       struct ab8500 *ab8500;
+
+       if (!dev)
+               return -EINVAL;
+       ab8500 = dev_get_drvdata(dev->parent);
+       return ab8500 ? (int)ab8500->chip_id : -EINVAL;
 }
 
 static int set_register_interruptible(struct ab8500 *ab8500, u8 bank,