* [PATCH] eth: fbnic: Avoid garbage value in fbnic_mac_get_sensor_asic()
@ 2024-12-24 2:27 Su Hui
2024-12-27 18:56 ` Jakub Kicinski
0 siblings, 1 reply; 2+ messages in thread
From: Su Hui @ 2024-12-24 2:27 UTC (permalink / raw)
To: alexanderduyck, kuba, kernel-team, andrew+netdev, davem, edumazet,
pabeni
Cc: Su Hui, sanmanpradhan, mohsin.bashr, kalesh-anakkur.purayil,
netdev, linux-kernel, kernel-janitors
'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
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] eth: fbnic: Avoid garbage value in fbnic_mac_get_sensor_asic()
2024-12-24 2:27 [PATCH] eth: fbnic: Avoid garbage value in fbnic_mac_get_sensor_asic() Su Hui
@ 2024-12-27 18:56 ` Jakub Kicinski
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2024-12-27 18:56 UTC (permalink / raw)
To: Su Hui
Cc: alexanderduyck, kernel-team, andrew+netdev, davem, edumazet,
pabeni, sanmanpradhan, mohsin.bashr, kalesh-anakkur.purayil,
netdev, linux-kernel, kernel-janitors
On Tue, 24 Dec 2024 10:27:29 +0800 Su Hui wrote:
> '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.
Argh, this function should send a FW command to read the sensors,
it does nothing today :/ Looks like an upstreaming fail..
If you'd like to fix this please just remove the body of the function
entirely and return -EOPNOTSUPP. We'll have to follow up in net-next
to fill in the gaps in sensor reading.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-12-27 18:56 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-24 2:27 [PATCH] eth: fbnic: Avoid garbage value in fbnic_mac_get_sensor_asic() Su Hui
2024-12-27 18:56 ` Jakub Kicinski
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).