All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: tcpm: qcom: initialize currsrc explicitly
@ 2026-07-13  8:06 Alexey V. Vissarionov
  2026-07-13  8:34 ` Bryan O'Donoghue
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey V. Vissarionov @ 2026-07-13  8:06 UTC (permalink / raw)
  To: Bryan O'Donoghue
  Cc: gremlin, Heikki Krogerus, Greg Kroah-Hartman, Guenter Roeck,
	Casey Connolly, linux-arm-msm, linux-usb, lvc-project

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.

Fixes: a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
Signed-off-by: Alexey V. Vissarionov <gremlin@altlinux.org>
---
 drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
index bf985efe1cd6bea4..d7cb69cf6044841b 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
@@ -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;
 


-- 
Alexey V. Vissarionov
gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii
GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: typec: tcpm: qcom: initialize currsrc explicitly
  2026-07-13  8:06 [PATCH] usb: typec: tcpm: qcom: initialize currsrc explicitly Alexey V. Vissarionov
@ 2026-07-13  8:34 ` Bryan O'Donoghue
  2026-07-13 18:22   ` Alexey V. Vissarionov
  0 siblings, 1 reply; 3+ messages in thread
From: Bryan O'Donoghue @ 2026-07-13  8:34 UTC (permalink / raw)
  To: Alexey V. Vissarionov
  Cc: Heikki Krogerus, Greg Kroah-Hartman, Guenter Roeck,
	Casey Connolly, linux-arm-msm, linux-usb, lvc-project

On 13/07/2026 09:06, Alexey V. Vissarionov wrote:
> 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.
> 
> Fixes: a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
> Signed-off-by: Alexey V. Vissarionov <gremlin@altlinux.org>
> ---
>   drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
> index bf985efe1cd6bea4..d7cb69cf6044841b 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
> @@ -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.

Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

---
bod

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: typec: tcpm: qcom: initialize currsrc explicitly
  2026-07-13  8:34 ` Bryan O'Donoghue
@ 2026-07-13 18:22   ` Alexey V. Vissarionov
  0 siblings, 0 replies; 3+ messages in thread
From: Alexey V. Vissarionov @ 2026-07-13 18:22 UTC (permalink / raw)
  To: Bryan O'Donoghue
  Cc: Alexey V. Vissarionov, Heikki Krogerus, Greg Kroah-Hartman,
	Guenter Roeck, Casey Connolly, linux-arm-msm, linux-usb,
	lvc-project

Good ${greeting_time}!

On 2026-07-13 09:34:22 +0100, Bryan O'Donoghue wrote:

 > On 13/07/2026 09:06, Alexey V. Vissarionov wrote:
 >> 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.
 >> [...]
 >> Fixes: a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMIC
 >> Type-C driver")
 >> Signed-off-by: Alexey V. Vissarionov <gremlin@altlinux.org>
 > This patch makes sense but doesn't require a Fixes: tag.
 > With that changed.
 > Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>

ACK. Updated patch follows.


-- 
Alexey V. Vissarionov
gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii
GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-07-13 18:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-13  8:06 [PATCH] usb: typec: tcpm: qcom: initialize currsrc explicitly Alexey V. Vissarionov
2026-07-13  8:34 ` Bryan O'Donoghue
2026-07-13 18:22   ` Alexey V. Vissarionov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.