From: Joe Damato <joe@dama.to>
To: Chandra Mohan Sundar <chandramohan.explore@gmail.com>
Cc: sgoutham@marvell.com, lcherian@marvell.com, gakula@marvell.com,
jerinj@marvell.com, hkelam@marvell.com, sbhatta@marvell.com,
andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, shuah@kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev
Subject: Re: [PATCH net] Octeontx2-af: Fix negative array index read warning
Date: Mon, 11 Aug 2025 16:37:14 -0700 [thread overview]
Message-ID: <aJp-qm55O_ka7vSv@MacBook-Air.local> (raw)
In-Reply-To: <20250810180339.228231-1-chandramohan.explore@gmail.com>
On Sun, Aug 10, 2025 at 11:33:27PM +0530, Chandra Mohan Sundar wrote:
> The cgx_get_cgxid function may return a negative value.
> Using this value directly as an array index triggers Coverity warnings.
>
> Validate the returned value and handle the case gracefully.
>
> Signed-off-by: Chandra Mohan Sundar <chandramohan.explore@gmail.com>
> ---
> drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> index 8375f18c8e07..b14de93a2481 100644
> --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c
> @@ -3005,6 +3005,8 @@ static int cgx_print_fwdata(struct seq_file *s, int lmac_id)
> return -EAGAIN;
>
> cgx_id = cgx_get_cgxid(cgxd);
> + if (cgx_id < 0)
> + return -EINVAL;
>
> if (rvu->hw->lmac_per_cgx == CGX_LMACS_USX)
> fwdata = &rvu->fwdata->cgx_fw_data_usx[cgx_id][lmac_id];
A couple pieces of feedback for you:
1. Since this is a fixes it needs a Fixes tag and a commit SHA that it is fixing.
2. cgx_get_cgxid is called in 3 places, so your patch would probably need to
be expanded to fix all uses?
Overall though, did you somehow trigger this issue?
It seems like all cases where cgx_get_cgxid is used it would be extremely
difficult (maybe impossible?) for cgxd to be NULL and for it to return a
negative value.
next prev parent reply other threads:[~2025-08-11 23:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-10 18:03 [PATCH net] Octeontx2-af: Fix negative array index read warning Chandra Mohan Sundar
2025-08-11 23:37 ` Joe Damato [this message]
2025-08-12 19:01 ` Chandra Mohan Sundar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aJp-qm55O_ka7vSv@MacBook-Air.local \
--to=joe@dama.to \
--cc=andrew+netdev@lunn.ch \
--cc=chandramohan.explore@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=gakula@marvell.com \
--cc=hkelam@marvell.com \
--cc=jerinj@marvell.com \
--cc=kuba@kernel.org \
--cc=lcherian@marvell.com \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sbhatta@marvell.com \
--cc=sgoutham@marvell.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox