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>
This commit is contained in:
Christophe JAILLET 2017-08-07 00:37:55 +02:00 committed by Sebastian Reichel
parent 46cecd130d
commit 096fc160b7

View File

@ -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);
}