diff mbox series

net: b44: uninitialized variable in multiple places in b44.c

Message ID 20241219043410.1912288-1-topofeverest8848@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: b44: uninitialized variable in multiple places in b44.c | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 40 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-19--12-00 (tests: 881)

Commit Message

Roshan Khatri Dec. 19, 2024, 4:34 a.m. UTC
smatch reported uninitialized variable in multiples places in b44.c.
This patch fixes the uniinitialized variable errors in multiple places
reported by smatch.

Signed-off-by: Roshan Khatri <topofeverest8848@gmail.com>
---
 drivers/net/ethernet/broadcom/b44.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Michal Swiatkowski Dec. 19, 2024, 6:33 a.m. UTC | #1
On Thu, Dec 19, 2024 at 04:34:10AM +0000, Roshan Khatri wrote:
> smatch reported uninitialized variable in multiples places in b44.c.
> This patch fixes the uniinitialized variable errors in multiple places
> reported by smatch.
> 

You need fixes tag with the commit that introduced the issue when
targetting net. Like here for example [1]

[1] https://lore.kernel.org/netdev/CANn89i+yvyPMU1SE=p3Mm1S=UexsXSa4gzH3heUg17sa+iFK9w@mail.gmail.com/T/#t

> Signed-off-by: Roshan Khatri <topofeverest8848@gmail.com>
> ---
>  drivers/net/ethernet/broadcom/b44.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
> index e5809ad5eb82..9a466c5c4b6c 100644
> --- a/drivers/net/ethernet/broadcom/b44.c
> +++ b/drivers/net/ethernet/broadcom/b44.c
> @@ -314,7 +314,7 @@ static int b44_mdio_write_phylib(struct mii_bus *bus, int phy_id, int location,
>  
>  static int b44_phy_reset(struct b44 *bp)
>  {
> -	u32 val;
> +	u32 val = 0;
>  	int err;
>  
>  	if (bp->flags & B44_FLAG_EXTERNAL_PHY)
> @@ -414,7 +414,7 @@ static inline void b44_wap54g10_workaround(struct b44 *bp)
>  
>  static int b44_setup_phy(struct b44 *bp)
>  {
> -	u32 val;
> +	u32 val = 0;
>  	int err;
>  
>  	b44_wap54g10_workaround(bp);
> @@ -512,7 +512,7 @@ static void b44_link_report(struct b44 *bp)
>  
>  static void b44_check_phy(struct b44 *bp)
>  {
> -	u32 bmsr, aux;
> +	u32 bmsr = 0, aux = 0;
>  
>  	if (bp->flags & B44_FLAG_EXTERNAL_PHY) {
>  		bp->flags |= B44_FLAG_100_BASE_T;
> @@ -544,7 +544,7 @@ static void b44_check_phy(struct b44 *bp)
>  		if (!netif_carrier_ok(bp->dev) &&
>  		    (bmsr & BMSR_LSTATUS)) {
>  			u32 val = br32(bp, B44_TX_CTRL);
> -			u32 local_adv, remote_adv;
> +			u32 local_adv = 0, remote_adv = 0;
This two are real problems, because if the flag isn't clear, or first
read fails the variables won't be initialized when used.

>  
>  			if (bp->flags & B44_FLAG_FULL_DUPLEX)
>  				val |= TX_CTRL_DUPLEX;
> @@ -1786,7 +1786,7 @@ static void b44_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *inf
>  static int b44_nway_reset(struct net_device *dev)
>  {
>  	struct b44 *bp = netdev_priv(dev);
> -	u32 bmcr;
> +	u32 bmcr = 0;

The rest doesn't look like unitialized, you passing a pointer and
filling it with a value. Can't see the branch when the value is left
without filling, but maybe I don't see something obvious.

BTW, you have many "incorrect type in assignment" in cnic.c file.

Thanks
>  	int r;
>  
>  	spin_lock_irq(&bp->lock);
> -- 
> 2.34.1
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index e5809ad5eb82..9a466c5c4b6c 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -314,7 +314,7 @@  static int b44_mdio_write_phylib(struct mii_bus *bus, int phy_id, int location,
 
 static int b44_phy_reset(struct b44 *bp)
 {
-	u32 val;
+	u32 val = 0;
 	int err;
 
 	if (bp->flags & B44_FLAG_EXTERNAL_PHY)
@@ -414,7 +414,7 @@  static inline void b44_wap54g10_workaround(struct b44 *bp)
 
 static int b44_setup_phy(struct b44 *bp)
 {
-	u32 val;
+	u32 val = 0;
 	int err;
 
 	b44_wap54g10_workaround(bp);
@@ -512,7 +512,7 @@  static void b44_link_report(struct b44 *bp)
 
 static void b44_check_phy(struct b44 *bp)
 {
-	u32 bmsr, aux;
+	u32 bmsr = 0, aux = 0;
 
 	if (bp->flags & B44_FLAG_EXTERNAL_PHY) {
 		bp->flags |= B44_FLAG_100_BASE_T;
@@ -544,7 +544,7 @@  static void b44_check_phy(struct b44 *bp)
 		if (!netif_carrier_ok(bp->dev) &&
 		    (bmsr & BMSR_LSTATUS)) {
 			u32 val = br32(bp, B44_TX_CTRL);
-			u32 local_adv, remote_adv;
+			u32 local_adv = 0, remote_adv = 0;
 
 			if (bp->flags & B44_FLAG_FULL_DUPLEX)
 				val |= TX_CTRL_DUPLEX;
@@ -1786,7 +1786,7 @@  static void b44_get_drvinfo (struct net_device *dev, struct ethtool_drvinfo *inf
 static int b44_nway_reset(struct net_device *dev)
 {
 	struct b44 *bp = netdev_priv(dev);
-	u32 bmcr;
+	u32 bmcr = 0;
 	int r;
 
 	spin_lock_irq(&bp->lock);