This patch prevents NULL pointer error cauesed by unregistering unregistered
exton notifier block. At the probing time of charger manager, it tries to
remove extcon notifier block when it fails to initialize them. It has to be
applied for only registered one. Otherwise, it'd make kernel panic. To make it
work right, it checks extcon_specific_cable_nb's extcon_dev node. If extcon
cable notifier block was registered successfully, it has proper extcon_dev
pointer if not so it has NULL pointer.

Signed-off-by: Jonghwa Lee <[email protected]>
Signed-off-by: Myungjoo Ham <[email protected]>
---
 drivers/power/charger-manager.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/power/charger-manager.c b/drivers/power/charger-manager.c
index 7d1bcde..c55a7dc 100644
--- a/drivers/power/charger-manager.c
+++ b/drivers/power/charger-manager.c
@@ -1666,7 +1666,9 @@ err_reg_extcon:
                charger = &desc->charger_regulators[i];
                for (j = 0; j < charger->num_cables; j++) {
                        struct charger_cable *cable = &charger->cables[j];
-                       extcon_unregister_interest(&cable->extcon_dev);
+                       /* Remove notifier block if only edev exists */
+                       if (cable->extcon_dev.edev)
+                               extcon_unregister_interest(&cable->extcon_dev);
                }
 
                regulator_put(desc->charger_regulators[i].consumer);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to