[PATCH] usb: typec: intel_pmc_mux: Zero initialize num_ports in pmc_usb_probe()

Nathan Chancellor posted 1 patch 1 month, 1 week ago
drivers/usb/typec/mux/intel_pmc_mux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] usb: typec: intel_pmc_mux: Zero initialize num_ports in pmc_usb_probe()
Posted by Nathan Chancellor 1 month, 1 week ago
Clang warns (or errors with CONFIG_WERROR=y / W=e):

  drivers/usb/typec/mux/intel_pmc_mux.c:740:3: error: variable 'num_ports' is uninitialized when used here [-Werror,-Wuninitialized]
    740 |                 num_ports++;
        |                 ^~~~~~~~~

This should have been initialized to zero. Do so now to clean up the
warning and ensure num_ports does not use uninitialized memory.

Fixes: 8bdb0b3830ea ("usb: typec: intel_pmc_mux: combine kzalloc + kcalloc")
Reported-by: kernelci.org bot <bot@kernelci.org>
Closes: https://lore.kernel.org/177793914437.2560.9287713196857718000@997d03828cfd/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/usb/typec/mux/intel_pmc_mux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
index e22b070a140f..219a32da1348 100644
--- a/drivers/usb/typec/mux/intel_pmc_mux.c
+++ b/drivers/usb/typec/mux/intel_pmc_mux.c
@@ -732,7 +732,7 @@ static int pmc_usb_probe(struct platform_device *pdev)
 {
 	struct fwnode_handle *fwnode = NULL;
 	struct pmc_usb *pmc;
-	u8 num_ports;
+	u8 num_ports = 0;
 	int i = 0;
 	int ret;
 

---
base-commit: 25bd55f46032656012eecdc6eabd62f2685a2ccc
change-id: 20260506-typec-intel_pmc_mux-fix-uninit-num_ports-3567859e7deb

Best regards,
--  
Cheers,
Nathan
Re: [PATCH] usb: typec: intel_pmc_mux: Zero initialize num_ports in pmc_usb_probe()
Posted by Heikki Krogerus 1 month, 1 week ago
On Wed, May 06, 2026 at 02:05:54PM +0800, Nathan Chancellor wrote:
> Clang warns (or errors with CONFIG_WERROR=y / W=e):
> 
>   drivers/usb/typec/mux/intel_pmc_mux.c:740:3: error: variable 'num_ports' is uninitialized when used here [-Werror,-Wuninitialized]
>     740 |                 num_ports++;
>         |                 ^~~~~~~~~
> 
> This should have been initialized to zero. Do so now to clean up the
> warning and ensure num_ports does not use uninitialized memory.
> 
> Fixes: 8bdb0b3830ea ("usb: typec: intel_pmc_mux: combine kzalloc + kcalloc")
> Reported-by: kernelci.org bot <bot@kernelci.org>
> Closes: https://lore.kernel.org/177793914437.2560.9287713196857718000@997d03828cfd/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  drivers/usb/typec/mux/intel_pmc_mux.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c
> index e22b070a140f..219a32da1348 100644
> --- a/drivers/usb/typec/mux/intel_pmc_mux.c
> +++ b/drivers/usb/typec/mux/intel_pmc_mux.c
> @@ -732,7 +732,7 @@ static int pmc_usb_probe(struct platform_device *pdev)
>  {
>  	struct fwnode_handle *fwnode = NULL;
>  	struct pmc_usb *pmc;
> -	u8 num_ports;
> +	u8 num_ports = 0;
>  	int i = 0;
>  	int ret;
>  

thanks,

-- 
heikki