mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Su Hui <suhui@nfschina.com>
To: alexanderduyck@fb.com, kuba@kernel.org, kernel-team@meta.com,
	andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com
Cc: Su Hui <suhui@nfschina.com>,
	sanmanpradhan@meta.com, mohsin.bashr@gmail.com,
	kalesh-anakkur.purayil@broadcom.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] eth: fbnic: Avoid garbage value in fbnic_mac_get_sensor_asic()
Date: Tue, 24 Dec 2024 10:27:29 +0800	[thread overview]
Message-ID: <20241224022728.675609-1-suhui@nfschina.com> (raw)

'fw_cmpl' is uninitialized which makes 'sensor' and '*val' to be stored
garbage value. Initialize 'fw_cmpl' with 'fdb->cmpl_data' to fix this
problem.

Fixes: d85ebade02e8 ("eth: fbnic: Add hardware monitoring support via HWMON interface")
Signed-off-by: Su Hui <suhui@nfschina.com>
---
 drivers/net/ethernet/meta/fbnic/fbnic_mac.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_mac.c b/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
index 80b82ff12c4d..ab1d1864d7a8 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
@@ -688,15 +688,18 @@ fbnic_mac_get_eth_mac_stats(struct fbnic_dev *fbd, bool reset,
 
 static int fbnic_mac_get_sensor_asic(struct fbnic_dev *fbd, int id, long *val)
 {
-	struct fbnic_fw_completion fw_cmpl;
+	struct fbnic_fw_completion *fw_cmpl = fbd->cmpl_data;
 	s32 *sensor;
 
+	if (!fw_cmpl)
+		return -EINVAL;
+
 	switch (id) {
 	case FBNIC_SENSOR_TEMP:
-		sensor = &fw_cmpl.tsene.millidegrees;
+		sensor = &fw_cmpl->tsene.millidegrees;
 		break;
 	case FBNIC_SENSOR_VOLTAGE:
-		sensor = &fw_cmpl.tsene.millivolts;
+		sensor = &fw_cmpl->tsene.millivolts;
 		break;
 	default:
 		return -EINVAL;
-- 
2.30.2


             reply	other threads:[~2024-12-24  2:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-24  2:27 Su Hui [this message]
2024-12-27 18:56 ` Jakub Kicinski

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=20241224022728.675609-1-suhui@nfschina.com \
    --to=suhui@nfschina.com \
    --cc=alexanderduyck@fb.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kalesh-anakkur.purayil@broadcom.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mohsin.bashr@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sanmanpradhan@meta.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®