* [PATCH net-next] octeontx2-af: Fix uninitialized variable in debugfs
@ 2019-11-21 9:21 Dan Carpenter
2019-11-21 9:41 ` Sunil Kovvuri
2019-11-21 19:42 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2019-11-21 9:21 UTC (permalink / raw)
To: Sunil Goutham, Linu Cherian
Cc: Geetha sowjanya, Jerin Jacob, David S. Miller, netdev,
kernel-janitors
If rvu_get_blkaddr() fails, then this rvu_cgx_nix_cuml_stats() returns
zero and we write some uninitialized data into the debugfs output.
On the error paths, the use of the uninitialized "*stat" is harmless,
but it will lead to a Smatch warning (static analysis) and a UBSan
warning (runtime analysis) so we should prevent that as well.
Fixes: f967488d095e ("octeontx2-af: Add per CGX port level NIX Rx/Tx counters")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
index 0bbb2eb1446e..11e5921c55b9 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c
@@ -608,6 +608,8 @@ int rvu_cgx_nix_cuml_stats(struct rvu *rvu, void *cgxd, int lmac_id,
u16 pcifunc;
int pf, lf;
+ *stat = 0;
+
if (!cgxd || !rvu)
return -EINVAL;
@@ -624,7 +626,6 @@ int rvu_cgx_nix_cuml_stats(struct rvu *rvu, void *cgxd, int lmac_id,
return 0;
block = &rvu->hw->block[blkaddr];
- *stat = 0;
for (lf = 0; lf < block->lf.max; lf++) {
/* Check if a lf is attached to this PF or one of its VFs */
if (!((block->fn_map[lf] & ~RVU_PFVF_FUNC_MASK) == (pcifunc &
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net-next] octeontx2-af: Fix uninitialized variable in debugfs
2019-11-21 9:21 [PATCH net-next] octeontx2-af: Fix uninitialized variable in debugfs Dan Carpenter
@ 2019-11-21 9:41 ` Sunil Kovvuri
2019-11-21 19:42 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Sunil Kovvuri @ 2019-11-21 9:41 UTC (permalink / raw)
To: Dan Carpenter
Cc: Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob,
David S. Miller, Linux Netdev List, kernel-janitors
On Thu, Nov 21, 2019 at 2:53 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> If rvu_get_blkaddr() fails, then this rvu_cgx_nix_cuml_stats() returns
> zero and we write some uninitialized data into the debugfs output.
>
> On the error paths, the use of the uninitialized "*stat" is harmless,
> but it will lead to a Smatch warning (static analysis) and a UBSan
> warning (runtime analysis) so we should prevent that as well.
>
Thanks for the fix.
Thanks,
Sunil.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] octeontx2-af: Fix uninitialized variable in debugfs
2019-11-21 9:21 [PATCH net-next] octeontx2-af: Fix uninitialized variable in debugfs Dan Carpenter
2019-11-21 9:41 ` Sunil Kovvuri
@ 2019-11-21 19:42 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-11-21 19:42 UTC (permalink / raw)
To: dan.carpenter; +Cc: sgoutham, lcherian, gakula, jerinj, netdev, kernel-janitors
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Thu, 21 Nov 2019 12:21:46 +0300
> If rvu_get_blkaddr() fails, then this rvu_cgx_nix_cuml_stats() returns
> zero and we write some uninitialized data into the debugfs output.
>
> On the error paths, the use of the uninitialized "*stat" is harmless,
> but it will lead to a Smatch warning (static analysis) and a UBSan
> warning (runtime analysis) so we should prevent that as well.
>
> Fixes: f967488d095e ("octeontx2-af: Add per CGX port level NIX Rx/Tx counters")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-11-21 19:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-21 9:21 [PATCH net-next] octeontx2-af: Fix uninitialized variable in debugfs Dan Carpenter
2019-11-21 9:41 ` Sunil Kovvuri
2019-11-21 19:42 ` David Miller
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).