浏览代码

mfd: ab8500-core improved error handling in get_chip_id

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>
Mattias Wallin 14 年之前
父节点
当前提交
6bce7bf1a1
共有 1 个文件被更改,包括 6 次插入2 次删除
  1. 6 2
      drivers/mfd/ab8500-core.c

+ 6 - 2
drivers/mfd/ab8500-core.c

@@ -103,8 +103,12 @@ static const int ab8500_irq_regoffset[AB8500_NUM_IRQ_REGS] = {
 
 
 static int ab8500_get_chip_id(struct device *dev)
 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,
 static int set_register_interruptible(struct ab8500 *ab8500, u8 bank,