summaryrefslogtreecommitdiffstats
path: root/drivers/power
diff options
context:
space:
mode:
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>2017-08-07 00:37:55 +0200
committerSebastian Reichel <sebastian.reichel@collabora.co.uk>2017-08-11 18:53:18 +0200
commit096fc160b706237b6643a15a8e13690de238af0f (patch)
tree2f9c76eae99c6cdd224e7d3151bf6bc9b0d7822b /drivers/power
parentpower: supply: Fix power_supply_am_i_supplied to return -ENODEV when apropriate (diff)
downloadlinux-096fc160b706237b6643a15a8e13690de238af0f.tar.xz
linux-096fc160b706237b6643a15a8e13690de238af0f.zip
power: supply: charger-manager: Fix a NULL pointer dereference in 'charger_manager_probe()'
'devm_kzalloc()' can return NULL. Return -ENOMEM in this case in order to avoid a NULL pointer dereference later on. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Diffstat (limited to 'drivers/power')
-rw-r--r--drivers/power/supply/charger-manager.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c
index adc3761831e1..52a49857e20f 100644
--- a/drivers/power/supply/charger-manager.c
+++ b/drivers/power/supply/charger-manager.c
@@ -1645,6 +1645,8 @@ static int charger_manager_probe(struct platform_device *pdev)
/* Initialize alarm timer */
if (alarmtimer_get_rtcdev()) {
cm_timer = devm_kzalloc(cm->dev, sizeof(*cm_timer), GFP_KERNEL);
+ if (!cm_timer)
+ return -ENOMEM;
alarm_init(cm_timer, ALARM_BOOTTIME, cm_timer_func);
}