usb: typec: tcpm: qcom: initialize currsrc explicitly
PATCH 1/1 usb: typec: tcpm: qcom: initialize currsrc explicitly
When regmap_read() fails, the execution goes to done: label, where currsrc is passed to rp_sel_to_name() and used as an index after a proper check. However, to make this situation easier to notice, an explicit initialization of currsrc with obviously impossible value is suggested. Alas, we can't simply use zero value here because it means TYPEC_SRC_RP_SEL_80UA.
Found by ALT Linux Team (altlinux.org) and Linux Verification Center (linuxtesting.org) using SVACE.
--- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c +2 -2
@@ -461,8 +461,8 @@ static int qcom_pmic_typec_port_set_cc(struct tcpc_dev *tcpc,struct pmic_typec *tcpm =tcpc_to_tcpm (tcpc);struct pmic_typec_port *pmic_typec_port = tcpm->pmic_typec_port;struct device *dev = pmic_typec_port->dev; -unsigned int mode, currsrc; -unsigned int misc; +unsigned int currsrc =0xFF ;/* error, easy to notice in the log */ +unsigned int mode, misc;unsigned long flags;int ret;
Signature · 3 lines
Alexey V. Vissarionov gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net
Quoted 23 lines · Alexey V. Vissarionov
When
regmap_read()fails, the execution goes to done: label, where currsrc is passed torp_sel_to_name()and used as an index after a proper check. However, to make this situation easier to notice, an explicit initialization of currsrc with obviously impossible value is suggested. Alas, we can't simply use zero value here because it meansTYPEC_SRC_RP_SEL_80UA.Found by ALT Linux Team (altlinux.org) and Linux Verification Center (linuxtesting.org) using SVACE.
Fixes a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMIC Type-C driver")Signed-off-by Alexey V. Vissarionov <[email protected]>--- drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c +0
-0
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c static int qcom_pmic_typec_port_set_cc(struct tcpc_dev *tcpc, · line 468
Quoted 10 lines
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c +2
-2@@ -461,8 +461,8 @@ static int qcom_pmic_typec_port_set_cc(struct tcpc_dev *tcpc,struct pmic_typec *tcpm =tcpc_to_tcpm (tcpc);struct pmic_typec_port *pmic_typec_port = tcpm->pmic_typec_port;struct device *dev = pmic_typec_port->dev; -unsigned int mode, currsrc; -unsigned int misc; +unsigned int currsrc =0xFF ;/* error, easy to notice in the log */ +unsigned int mode, misc;unsigned long flags;int ret;
This patch makes sense but doesn't require a Fixes: tag.
With that changed.
---
bod
Good ${greeting_time}!
Quoted 10 lines · Bryan O'Donoghue
Quoted 9 lines · Alexey V. Vissarionov
When
regmap_read()fails, the execution goes to done: label, where currsrc is passed torp_sel_to_name()and used as an index after a proper check. However, to make this situation easier to notice, an explicit initialization of currsrc with obviously impossible value is suggested.[...]Fixes a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMICType-C driver")
Signed-off-by Alexey V. Vissarionov <[email protected]>
Quoted 3 lines
This patch makes sense but doesn't require a Fixes: tag. With that changed.
Reviewed-by Bryan O'Donoghue <[email protected]>
ACK. Updated patch follows.
Signature · 3 lines
Alexey V. Vissarionov gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net