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

Commit 00ad633e authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy Committed by Gerrit - the friendly Code Review server
Browse files

power: supply: qti_battery_charger: Fix NULL pointer dereference



With psy initialized in battery_chg_init_psy(), read_property_id()
when called from battery_chg_parse_dt() can try accessing
psy->desc->name when dynamic debugging is enabled. Fix it.

Change-Id: I88114ea9779d5113524b8b15659bf8bafe6364ed
Signed-off-by: default avatarSubbaraman Narayanamurthy <quic_subbaram@quicinc.com>
parent c73b8b29
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -396,6 +396,7 @@ static int write_property_id(struct battery_chg_dev *bcdev,
	req_msg.hdr.type = MSG_TYPE_REQ_RESP;
	req_msg.hdr.opcode = pst->opcode_set;

	if (pst->psy)
		pr_debug("psy: %s prop_id: %u val: %u\n", pst->psy->desc->name,
			req_msg.property_id, val);

@@ -414,6 +415,7 @@ static int read_property_id(struct battery_chg_dev *bcdev,
	req_msg.hdr.type = MSG_TYPE_REQ_RESP;
	req_msg.hdr.opcode = pst->opcode_get;

	if (pst->psy)
		pr_debug("psy: %s prop_id: %u\n", pst->psy->desc->name,
			req_msg.property_id);

@@ -429,6 +431,7 @@ static int get_property_id(struct psy_state *pst,
		if (pst->map[i] == prop)
			return i;

	if (pst->psy)
		pr_err("No property id for property %d in psy %s\n", prop,
			pst->psy->desc->name);