diff mbox series

[v2] eth: fbnic: Avoid garbage value in fbnic_mac_get_sensor_asic()

Message ID 20241230014242.14562-1-suhui@nfschina.com (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series [v2] eth: fbnic: Avoid garbage value in fbnic_mac_get_sensor_asic() | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 24 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-30--18-00 (tests: 881)

Commit Message

Su Hui Dec. 30, 2024, 1:42 a.m. UTC
'fw_cmpl' is uninitialized which makes 'sensor' and '*val' to be stored
garbage value. Remove the whole body of fbnic_mac_get_sensor_asic() and
return -EOPNOTSUPP to fix this problem.

Fixes: d85ebade02e8 ("eth: fbnic: Add hardware monitoring support via HWMON interface")
Signed-off-by: Su Hui <suhui@nfschina.com>
Suggested-by: Jakub Kicinski <kuba@kernel.org>
---
 drivers/net/ethernet/meta/fbnic/fbnic_mac.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

Comments

Michal Swiatkowski Dec. 30, 2024, 8 a.m. UTC | #1
On Mon, Dec 30, 2024 at 09:42:43AM +0800, Su Hui wrote:
> 'fw_cmpl' is uninitialized which makes 'sensor' and '*val' to be stored
> garbage value. Remove the whole body of fbnic_mac_get_sensor_asic() and
> return -EOPNOTSUPP to fix this problem.
> 
> Fixes: d85ebade02e8 ("eth: fbnic: Add hardware monitoring support via HWMON interface")
> Signed-off-by: Su Hui <suhui@nfschina.com>
> Suggested-by: Jakub Kicinski <kuba@kernel.org>
> ---
>  drivers/net/ethernet/meta/fbnic/fbnic_mac.c | 18 +-----------------
>  1 file changed, 1 insertion(+), 17 deletions(-)
> 
> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_mac.c b/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
> index 80b82ff12c4d..dd28c0f4c4b0 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
> @@ -688,23 +688,7 @@ 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;
Probably it should be:
*fw_cmpl = fbd->cmpl_data
but it is also never initialized.

> -	s32 *sensor;
> -
> -	switch (id) {
> -	case FBNIC_SENSOR_TEMP:
> -		sensor = &fw_cmpl.tsene.millidegrees;
> -		break;
> -	case FBNIC_SENSOR_VOLTAGE:
> -		sensor = &fw_cmpl.tsene.millivolts;
> -		break;
> -	default:
> -		return -EINVAL;
> -	}
> -
> -	*val = *sensor;
> -
> -	return 0;
> +	return -EOPNOTSUPP;

It is more like removing broken functionality than fixing (maybe whole
commit should be reverted). Anyway returning not support is also fine.

Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>

>  }
>  
>  static const struct fbnic_mac fbnic_mac_asic = {
> -- 
> 2.30.2
Jakub Kicinski Dec. 30, 2024, 4:52 p.m. UTC | #2
On Mon, 30 Dec 2024 09:00:20 +0100 Michal Swiatkowski wrote:
> > @@ -688,23 +688,7 @@ 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;  
> Probably it should be:
> *fw_cmpl = fbd->cmpl_data
> but it is also never initialized.

The other way around, the completion declared on the stack should be
the thing that gets assigned to the pointer in fbd :S

> > -	s32 *sensor;
> > -
> > -	switch (id) {
> > -	case FBNIC_SENSOR_TEMP:
> > -		sensor = &fw_cmpl.tsene.millidegrees;
> > -		break;
> > -	case FBNIC_SENSOR_VOLTAGE:
> > -		sensor = &fw_cmpl.tsene.millivolts;
> > -		break;
> > -	default:
> > -		return -EINVAL;
> > -	}
> > -
> > -	*val = *sensor;
> > -
> > -	return 0;
> > +	return -EOPNOTSUPP;  
> 
> It is more like removing broken functionality than fixing (maybe whole
> commit should be reverted). Anyway returning not support is also fine.

I defer to other maintainers. The gaps are trivial to fill in, we'll 
do so as soon as this patch makes it to net-next (this patch needs to
target net).
diff mbox series

Patch

diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_mac.c b/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
index 80b82ff12c4d..dd28c0f4c4b0 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_mac.c
@@ -688,23 +688,7 @@  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;
-	s32 *sensor;
-
-	switch (id) {
-	case FBNIC_SENSOR_TEMP:
-		sensor = &fw_cmpl.tsene.millidegrees;
-		break;
-	case FBNIC_SENSOR_VOLTAGE:
-		sensor = &fw_cmpl.tsene.millivolts;
-		break;
-	default:
-		return -EINVAL;
-	}
-
-	*val = *sensor;
-
-	return 0;
+	return -EOPNOTSUPP;
 }
 
 static const struct fbnic_mac fbnic_mac_asic = {