* Re: [PATCH v1] usb: typec: tcpm: qcom: initialize currsrc explicitly
2026-07-13 18:25 ` [PATCH v1] usb: typec: tcpm: qcom: initialize currsrc explicitly Alexey V. Vissarionov
@ 2026-07-14 8:26 ` Bryan O'Donoghue
2026-07-14 13:32 ` Heikki Krogerus
2026-07-14 13:47 ` Fedor Pchelkin
2 siblings, 0 replies; 5+ messages in thread
From: Bryan O'Donoghue @ 2026-07-14 8:26 UTC (permalink / raw)
To: Alexey V. Vissarionov, Bryan O'Donoghue
Cc: Heikki Krogerus, Greg Kroah-Hartman, Guenter Roeck,
Casey Connolly, linux-arm-msm, linux-usb, lvc-project
On 13/07/2026 19:25, 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.
>
> 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
>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] usb: typec: tcpm: qcom: initialize currsrc explicitly
2026-07-13 18:25 ` [PATCH v1] usb: typec: tcpm: qcom: initialize currsrc explicitly Alexey V. Vissarionov
2026-07-14 8:26 ` Bryan O'Donoghue
@ 2026-07-14 13:32 ` Heikki Krogerus
2026-07-14 13:47 ` Fedor Pchelkin
2 siblings, 0 replies; 5+ messages in thread
From: Heikki Krogerus @ 2026-07-14 13:32 UTC (permalink / raw)
To: Alexey V. Vissarionov
Cc: Bryan O'Donoghue, Greg Kroah-Hartman, Guenter Roeck,
Casey Connolly, linux-arm-msm, linux-usb, lvc-project
On Mon, Jul 13, 2026 at 09:25:00PM +0300, 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.
>
> Signed-off-by: Alexey V. Vissarionov <gremlin@altlinux.org>
Acked-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> 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
--
heikki
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] usb: typec: tcpm: qcom: initialize currsrc explicitly
2026-07-13 18:25 ` [PATCH v1] usb: typec: tcpm: qcom: initialize currsrc explicitly Alexey V. Vissarionov
2026-07-14 8:26 ` Bryan O'Donoghue
2026-07-14 13:32 ` Heikki Krogerus
@ 2026-07-14 13:47 ` Fedor Pchelkin
2026-07-14 16:47 ` Vasiliy Kovalev
2 siblings, 1 reply; 5+ messages in thread
From: Fedor Pchelkin @ 2026-07-14 13:47 UTC (permalink / raw)
To: Alexey V. Vissarionov, Vasiliy Kovalev
Cc: Bryan O'Donoghue, Heikki Krogerus, lvc-project,
Casey Connolly, Greg Kroah-Hartman, linux-usb, linux-arm-msm,
Guenter Roeck
On Mon, 13. Jul 21:25, 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.
>
> 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;
'mode' and 'misc' should be initialized as well. Though this all was
already covered with the patch [1], which got the review two weeks ago.
Note that it did initialize currsrc with zero value instead of 0xFF.
It's confusing a bit. Maybe [1] should be respinned now with
currsrc = 0xFF or whatever?
+Cc Vasiliy
[1]: https://lore.kernel.org/all/20260630120114.185169-1-kovalev@altlinux.org/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v1] usb: typec: tcpm: qcom: initialize currsrc explicitly
2026-07-14 13:47 ` Fedor Pchelkin
@ 2026-07-14 16:47 ` Vasiliy Kovalev
0 siblings, 0 replies; 5+ messages in thread
From: Vasiliy Kovalev @ 2026-07-14 16:47 UTC (permalink / raw)
To: Fedor Pchelkin
Cc: Bryan O'Donoghue, Heikki Krogerus, lvc-project,
Casey Connolly, Greg Kroah-Hartman, linux-usb, linux-arm-msm,
Guenter Roeck, Alexey V. Vissarionov
On 7/14/26 16:47, Fedor Pchelkin wrote:
> It's confusing a bit. Maybe [1] should be respinned now with
> currsrc = 0xFF or whatever?
Thanks, agree. v2 sent:
https://lore.kernel.org/all/20260714163913.151008-1-kovalev@altlinux.org/
>
> [1]: https://lore.kernel.org/all/20260630120114.185169-1-kovalev@altlinux.org/
^ permalink raw reply [flat|nested] 5+ messages in thread