Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eba3aa85 authored by Manu Gautam's avatar Manu Gautam Committed by Gerrit - the friendly Code Review server
Browse files

phy: msm: usb: Fix extcon vbus/id notifier_block list corruption



If driver fails to register extcon notifier from probe, it defers
same to work_queue which is invoked when extcon provider becomes
available (psy_nb is used for same). If power_supply notifier call
gets invoked back to back before extcon_register_work could
unregister psy_changed notifier, it results in driver registering
extcon notifier two times without unregister. This causes notifier_nb
list corruption where notifer_nb->next points to itself and any
extcon event later results in inifinite notifer calls causing
watchdog bite.

Change-Id: Ic7963971db198817e5643b6f3968cd8a4bc2e43c
Signed-off-by: default avatarManu Gautam <mgautam@codeaurora.org>
parent 44bdb591
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -3676,6 +3676,11 @@ static int msm_otg_extcon_register(struct msm_otg *motg)
	struct extcon_dev *edev;
	int ret = 0;

	if (motg->extcon_registered) {
		dev_info(&motg->pdev->dev, "extcon_nb already registered\n");
		return 0;
	}

	if (!of_property_read_bool(node, "extcon"))
		return 0;

@@ -3712,6 +3717,7 @@ static int msm_otg_extcon_register(struct msm_otg *motg)
			goto err;
		}
	}
	motg->extcon_registered = true;

	return 0;
err:
+2 −0
Original line number Diff line number Diff line
@@ -171,6 +171,7 @@ enum usb_id_state {
 * @extcon_id: Used for ID notification registration.
 * @vbus_nb: Notification callback for VBUS event.
 * @id_nb: Notification callback for ID event.
 * @extcon_registered: indicates if extcon notifier registered or not.
 * @dpdm_desc: Regulator descriptor for D+ and D- voting.
 * @dpdm_rdev: Regulator class device for dpdm regulator.
 * @dbg_idx: Dynamic debug buffer Index.
@@ -297,6 +298,7 @@ struct msm_otg {
	struct extcon_dev       *extcon_id;
	struct notifier_block   vbus_nb;
	struct notifier_block   id_nb;
	bool			extcon_registered;
	struct regulator_desc	dpdm_rdesc;
	struct regulator_dev	*dpdm_rdev;
/* Maximum debug message length */