From: Mattias Wallin Date: Thu, 2 Dec 2010 14:08:32 +0000 (+0100) Subject: mfd: ab8500-core improved error handling in get_chip_id X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=6bce7bf1a1f8a79a57ff69910c115e1d2ed8913d;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git mfd: ab8500-core improved error handling in get_chip_id We check for dev before dereferencing it. Signed-off-by: Mattias Wallin Signed-off-by: Samuel Ortiz --- diff --git a/drivers/mfd/ab8500-core.c b/drivers/mfd/ab8500-core.c index d9640a623ff4..e91b5b759004 100644 --- a/drivers/mfd/ab8500-core.c +++ b/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) { - 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,