mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ethan Carter Edwards <ethan@ethancedwards.com>
To: hariprasad <hkelam@marvell.com>
Cc: Sunil Goutham <sgoutham@marvell.com>,
	 Geetha sowjanya <gakula@marvell.com>,
	 Subbaraya Sundeep <sbhatta@marvell.com>,
	 Bharat Bhushan <bbhushan2@marvell.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	 "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>,
	 netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-hardening@vger.kernel.org,
	 Ethan Carter Edwards <ethan@ethancedwards.com>
Subject: [PATCH] octeontx2-af: Fix uninitialized scalar variable
Date: Mon, 10 Feb 2025 21:01:52 -0500	[thread overview]
Message-ID: <20250210-otx2_common-v1-1-954570a3666d@ethancedwards.com> (raw)

The variable *max_mtu* is uninitialized in the function
otx2_get_max_mtu. It is only assigned in the if-statement, leaving the
possibility of returning an uninitialized value.

1500 is the industry standard networking mtu and therefore should be the
default. If the function detects that the hardware custom sets the mtu,
then it will use it instead.

Addresses-Coverity-ID: 1636407 ("Uninitialized scalar variable")
Fixes: ab58a416c93f ("octeontx2-pf: cn10k: Get max mtu supported from admin function")
Signed-off-by: Ethan Carter Edwards <ethan@ethancedwards.com>
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
index 2b49bfec78692cf1f63c793ec49511607cda7c3e..6c1b03690a9c24c5232ff9f07befb1cc553490f7 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
@@ -1909,7 +1909,7 @@ u16 otx2_get_max_mtu(struct otx2_nic *pfvf)
 {
 	struct nix_hw_info *rsp;
 	struct msg_req *req;
-	u16 max_mtu;
+	u16 max_mtu = 1500;
 	int rc;
 
 	mutex_lock(&pfvf->mbox.lock);
@@ -1948,7 +1948,6 @@ u16 otx2_get_max_mtu(struct otx2_nic *pfvf)
 	if (rc) {
 		dev_warn(pfvf->dev,
 			 "Failed to get MTU from hardware setting default value(1500)\n");
-		max_mtu = 1500;
 	}
 	return max_mtu;
 }

---
base-commit: febbc555cf0fff895546ddb8ba2c9a523692fb55
change-id: 20250210-otx2_common-453132aa0a24

Best regards,
-- 
Ethan Carter Edwards <ethan@ethancedwards.com>


             reply	other threads:[~2025-02-11  2:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-11  2:01 Ethan Carter Edwards [this message]
2025-02-11  5:50 ` Michal Swiatkowski
2025-02-13 10:32   ` Paolo Abeni

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=20250210-otx2_common-v1-1-954570a3666d@ethancedwards.com \
    --to=ethan@ethancedwards.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bbhushan2@marvell.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gakula@marvell.com \
    --cc=hkelam@marvell.com \
    --cc=kuba@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    /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

all inboxes | Powered by JetHome®