* [PATCH v2 net-next 1/1] net: phy: fix use of uninit variable when setting PLCA config
@ 2023-01-18 15:47 Piergiorgio Beruto
2023-01-20 3:20 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Piergiorgio Beruto @ 2023-01-18 15:47 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: linux-kernel, netdev, Oleksij Rempel, mailhol.vincent,
sudheer.mogilappagari, sbhatta, linux-doc, wangjie125, corbet,
lkp, gal, gustavoars, bagasdotme
Coverity reported the following:
*** CID 1530573: (UNINIT)
drivers/net/phy/phy-c45.c:1036 in genphy_c45_plca_set_cfg()
1030 return ret;
1031
1032 val = ret;
1033 }
1034
1035 if (plca_cfg->node_cnt >= 0)
vvv CID 1530573: (UNINIT)
vvv Using uninitialized value "val".
1036 val = (val & ~MDIO_OATC14_PLCA_NCNT) |
1037 (plca_cfg->node_cnt << 8);
1038
1039 if (plca_cfg->node_id >= 0)
1040 val = (val & ~MDIO_OATC14_PLCA_ID) |
1041 (plca_cfg->node_id);
drivers/net/phy/phy-c45.c:1076 in genphy_c45_plca_set_cfg()
1070 return ret;
1071
1072 val = ret;
1073 }
1074
1075 if (plca_cfg->burst_cnt >= 0)
vvv CID 1530573: (UNINIT)
vvv Using uninitialized value "val".
1076 val = (val & ~MDIO_OATC14_PLCA_MAXBC) |
1077 (plca_cfg->burst_cnt << 8);
1078
1079 if (plca_cfg->burst_tmr >= 0)
1080 val = (val & ~MDIO_OATC14_PLCA_BTMR) |
1081 (plca_cfg->burst_tmr);
This is not actually creating a real problem because the path leading to
'val' being used uninitialized will eventually override the full content
of that variable before actually using it for writing the register.
However, the fix is simple and comes at basically no cost.
Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Fixes: 493323416fed ("drivers/net/phy: add helpers to get/set PLCA configuration")
Signed-off-by: Piergiorgio Beruto <piergiorgio.beruto@gmail.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
---
drivers/net/phy/phy-c45.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/phy/phy-c45.c b/drivers/net/phy/phy-c45.c
index cff83220595c..9f9565a4819d 100644
--- a/drivers/net/phy/phy-c45.c
+++ b/drivers/net/phy/phy-c45.c
@@ -999,8 +999,8 @@ EXPORT_SYMBOL_GPL(genphy_c45_plca_get_cfg);
int genphy_c45_plca_set_cfg(struct phy_device *phydev,
const struct phy_plca_cfg *plca_cfg)
{
+ u16 val = 0;
int ret;
- u16 val;
// PLCA IDVER is read-only
if (plca_cfg->version >= 0)
--
2.37.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 net-next 1/1] net: phy: fix use of uninit variable when setting PLCA config
2023-01-18 15:47 [PATCH v2 net-next 1/1] net: phy: fix use of uninit variable when setting PLCA config Piergiorgio Beruto
@ 2023-01-20 3:20 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-20 3:20 UTC (permalink / raw)
To: Piergiorgio Beruto
Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
linux-kernel, netdev, o.rempel, mailhol.vincent,
sudheer.mogilappagari, sbhatta, linux-doc, wangjie125, corbet,
lkp, gal, gustavoars, bagasdotme
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Wed, 18 Jan 2023 16:47:31 +0100 you wrote:
> Coverity reported the following:
>
> *** CID 1530573: (UNINIT)
> drivers/net/phy/phy-c45.c:1036 in genphy_c45_plca_set_cfg()
> 1030 return ret;
> 1031
> 1032 val = ret;
> 1033 }
> 1034
> 1035 if (plca_cfg->node_cnt >= 0)
> vvv CID 1530573: (UNINIT)
> vvv Using uninitialized value "val".
> 1036 val = (val & ~MDIO_OATC14_PLCA_NCNT) |
> 1037 (plca_cfg->node_cnt << 8);
> 1038
> 1039 if (plca_cfg->node_id >= 0)
> 1040 val = (val & ~MDIO_OATC14_PLCA_ID) |
> 1041 (plca_cfg->node_id);
> drivers/net/phy/phy-c45.c:1076 in genphy_c45_plca_set_cfg()
> 1070 return ret;
> 1071
> 1072 val = ret;
> 1073 }
> 1074
> 1075 if (plca_cfg->burst_cnt >= 0)
> vvv CID 1530573: (UNINIT)
> vvv Using uninitialized value "val".
> 1076 val = (val & ~MDIO_OATC14_PLCA_MAXBC) |
> 1077 (plca_cfg->burst_cnt << 8);
> 1078
> 1079 if (plca_cfg->burst_tmr >= 0)
> 1080 val = (val & ~MDIO_OATC14_PLCA_BTMR) |
> 1081 (plca_cfg->burst_tmr);
>
> [...]
Here is the summary with links:
- [v2,net-next,1/1] net: phy: fix use of uninit variable when setting PLCA config
https://git.kernel.org/netdev/net-next/c/1038bfb23649
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-01-20 3:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-18 15:47 [PATCH v2 net-next 1/1] net: phy: fix use of uninit variable when setting PLCA config Piergiorgio Beruto
2023-01-20 3:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).