bq2415x_charger: Fix null pointer dereference
authorPali Rohár <pali.rohar@gmail.com>
Mon, 21 Sep 2015 14:58:20 +0000 (16:58 +0200)
committerSebastian Reichel <sre@kernel.org>
Wed, 23 Sep 2015 16:59:19 +0000 (18:59 +0200)
Commit b68c3161430a (bq2415x_charger: Allow to load and use driver even if
notify device is not registered yet) introduced null pointer dereference in
case bq is NULL. This patch fixes it.

Fixes: b68c3161430a ("bq2415x_charger: Allow to load and use driver even if notify device is not registered yet")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
drivers/power/bq2415x_charger.c

index ec212b5be755c68cf28313fafe24910c2d0cfc03..4afd76848bce5bac52948e62c7c0bdf5aba79fa0 100644 (file)
@@ -1704,7 +1704,7 @@ error_4:
 error_3:
        bq2415x_power_supply_exit(bq);
 error_2:
-       if (bq->notify_node)
+       if (bq && bq->notify_node)
                of_node_put(bq->notify_node);
        kfree(name);
 error_1: