* [PATCH] usb: typec: qcom-pmic-typec: avoid uninit values in dev_dbg() error paths
@ 2026-06-30 12:01 Vasiliy Kovalev
2026-06-30 12:26 ` Bryan O'Donoghue
2026-07-03 12:04 ` Heikki Krogerus
0 siblings, 2 replies; 3+ messages in thread
From: Vasiliy Kovalev @ 2026-06-30 12:01 UTC (permalink / raw)
To: Bryan O'Donoghue, Heikki Krogerus, Greg Kroah-Hartman
Cc: linux-arm-msm, linux-usb, linux-kernel, lvc-project, kovalev
Several functions take a 'goto done' shortcut on regmap_read() (or
switch default) failure before assigning locals that the trailing
dev_dbg() then formats.
Initialize the affected locals at declaration.
Found by Linux Verification Center (linuxtesting.org) with Svace static
analysis tool.
Fixes: a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
Cc: stable@vger.kernel.org
Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
---
drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 9 +++++----
1 file changed, 5 insertions(+), 4 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 bf985efe1cd6..c8379cdcb6da 100644
--- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
+++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
@@ -366,7 +366,7 @@ static int qcom_pmic_typec_port_get_cc(struct tcpc_dev *tcpc,
struct pmic_typec_port *pmic_typec_port = tcpm->pmic_typec_port;
struct device *dev = pmic_typec_port->dev;
unsigned int misc, val;
- bool attached;
+ bool attached = false;
int ret = 0;
ret = regmap_read(pmic_typec_port->regmap,
@@ -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 mode = 0, currsrc = 0;
+ unsigned int misc = 0;
unsigned long flags;
int ret;
@@ -535,7 +535,8 @@ static int qcom_pmic_typec_port_set_vconn(struct tcpc_dev *tcpc, bool on)
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 orientation, misc, mask, value;
+ unsigned int orientation = 0, misc = 0, value = 0;
+ unsigned int mask;
unsigned long flags;
int ret;
--
2.50.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] usb: typec: qcom-pmic-typec: avoid uninit values in dev_dbg() error paths
2026-06-30 12:01 [PATCH] usb: typec: qcom-pmic-typec: avoid uninit values in dev_dbg() error paths Vasiliy Kovalev
@ 2026-06-30 12:26 ` Bryan O'Donoghue
2026-07-03 12:04 ` Heikki Krogerus
1 sibling, 0 replies; 3+ messages in thread
From: Bryan O'Donoghue @ 2026-06-30 12:26 UTC (permalink / raw)
To: Vasiliy Kovalev, Heikki Krogerus, Greg Kroah-Hartman
Cc: linux-arm-msm, linux-usb, linux-kernel, lvc-project
On 30/06/2026 13:01, Vasiliy Kovalev wrote:
> Several functions take a 'goto done' shortcut on regmap_read() (or
> switch default) failure before assigning locals that the trailing
> dev_dbg() then formats.
>
> Initialize the affected locals at declaration.
>
> Found by Linux Verification Center (linuxtesting.org) with Svace static
> analysis tool.
>
> Fixes: a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
> ---
> drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 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 bf985efe1cd6..c8379cdcb6da 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
> @@ -366,7 +366,7 @@ static int qcom_pmic_typec_port_get_cc(struct tcpc_dev *tcpc,
> struct pmic_typec_port *pmic_typec_port = tcpm->pmic_typec_port;
> struct device *dev = pmic_typec_port->dev;
> unsigned int misc, val;
> - bool attached;
> + bool attached = false;
> int ret = 0;
>
> ret = regmap_read(pmic_typec_port->regmap,
> @@ -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 mode = 0, currsrc = 0;
> + unsigned int misc = 0;
> unsigned long flags;
> int ret;
>
> @@ -535,7 +535,8 @@ static int qcom_pmic_typec_port_set_vconn(struct tcpc_dev *tcpc, bool on)
> 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 orientation, misc, mask, value;
> + unsigned int orientation = 0, misc = 0, value = 0;
> + unsigned int mask;
> unsigned long flags;
> int ret;
>
Reviewed-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
bod
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] usb: typec: qcom-pmic-typec: avoid uninit values in dev_dbg() error paths
2026-06-30 12:01 [PATCH] usb: typec: qcom-pmic-typec: avoid uninit values in dev_dbg() error paths Vasiliy Kovalev
2026-06-30 12:26 ` Bryan O'Donoghue
@ 2026-07-03 12:04 ` Heikki Krogerus
1 sibling, 0 replies; 3+ messages in thread
From: Heikki Krogerus @ 2026-07-03 12:04 UTC (permalink / raw)
To: Vasiliy Kovalev
Cc: Bryan O'Donoghue, Greg Kroah-Hartman, linux-arm-msm,
linux-usb, linux-kernel, lvc-project
On Tue, Jun 30, 2026 at 03:01:14PM +0300, Vasiliy Kovalev wrote:
> Several functions take a 'goto done' shortcut on regmap_read() (or
> switch default) failure before assigning locals that the trailing
> dev_dbg() then formats.
>
> Initialize the affected locals at declaration.
>
> Found by Linux Verification Center (linuxtesting.org) with Svace static
> analysis tool.
>
> Fixes: a4422ff22142 ("usb: typec: qcom: Add Qualcomm PMIC Type-C driver")
> Cc: stable@vger.kernel.org
> Signed-off-by: Vasiliy Kovalev <kovalev@altlinux.org>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 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 bf985efe1cd6..c8379cdcb6da 100644
> --- a/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
> +++ b/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
> @@ -366,7 +366,7 @@ static int qcom_pmic_typec_port_get_cc(struct tcpc_dev *tcpc,
> struct pmic_typec_port *pmic_typec_port = tcpm->pmic_typec_port;
> struct device *dev = pmic_typec_port->dev;
> unsigned int misc, val;
> - bool attached;
> + bool attached = false;
> int ret = 0;
>
> ret = regmap_read(pmic_typec_port->regmap,
> @@ -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 mode = 0, currsrc = 0;
> + unsigned int misc = 0;
> unsigned long flags;
> int ret;
>
> @@ -535,7 +535,8 @@ static int qcom_pmic_typec_port_set_vconn(struct tcpc_dev *tcpc, bool on)
> 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 orientation, misc, mask, value;
> + unsigned int orientation = 0, misc = 0, value = 0;
> + unsigned int mask;
> unsigned long flags;
> int ret;
>
> --
> 2.50.1
--
heikki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-03 12:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 12:01 [PATCH] usb: typec: qcom-pmic-typec: avoid uninit values in dev_dbg() error paths Vasiliy Kovalev
2026-06-30 12:26 ` Bryan O'Donoghue
2026-07-03 12:04 ` Heikki Krogerus
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox