All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] mlxsw: thermal: Fix null dereference of NULL temperature parameter
@ 2021-06-09 17:56 Colin King
  2021-06-09 18:07 ` Ido Schimmel
  2021-06-09 22:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Colin King @ 2021-06-09 17:56 UTC (permalink / raw)
  To: Jiri Pirko, Ido Schimmel, David S . Miller, Jakub Kicinski,
	Mykola Kostenok, Vadim Pasternak, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

The call to mlxsw_thermal_module_temp_and_thresholds_get passes a NULL
pointer for the temperature and this can be dereferenced in this function
if the mlxsw_reg_query call fails.  The simplist fix is to pass the
address of dummy temperature variable instead of a NULL pointer.

Addresses-Coverity: ("Explicit null dereferenced")
Fixes: 72a64c2fe9d8 ("mlxsw: thermal: Read module temperature thresholds using MTMP register")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/mellanox/mlxsw/core_thermal.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
index d54b67d0bda7..0998dcc9cac0 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c
@@ -743,7 +743,7 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
 			  struct mlxsw_thermal *thermal, u8 module)
 {
 	struct mlxsw_thermal_module *module_tz;
-	int crit_temp, emerg_temp;
+	int dummy_temp, crit_temp, emerg_temp;
 	u16 sensor_index;
 
 	sensor_index = MLXSW_REG_MTMP_MODULE_INDEX_MIN + module;
@@ -758,7 +758,7 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
 	/* Initialize all trip point. */
 	mlxsw_thermal_module_trips_reset(module_tz);
 	/* Read module temperature and thresholds. */
-	mlxsw_thermal_module_temp_and_thresholds_get(core, sensor_index, NULL,
+	mlxsw_thermal_module_temp_and_thresholds_get(core, sensor_index, &dummy_temp,
 						     &crit_temp, &emerg_temp);
 	/* Update trip point according to the module data. */
 	return mlxsw_thermal_module_trips_update(dev, core, module_tz,
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] mlxsw: thermal: Fix null dereference of NULL temperature parameter
  2021-06-09 17:56 [PATCH][next] mlxsw: thermal: Fix null dereference of NULL temperature parameter Colin King
@ 2021-06-09 18:07 ` Ido Schimmel
  2021-06-09 22:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Ido Schimmel @ 2021-06-09 18:07 UTC (permalink / raw)
  To: Colin King
  Cc: Jiri Pirko, Ido Schimmel, David S . Miller, Jakub Kicinski,
	Mykola Kostenok, Vadim Pasternak, netdev, kernel-janitors,
	linux-kernel

On Wed, Jun 09, 2021 at 06:56:57PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The call to mlxsw_thermal_module_temp_and_thresholds_get passes a NULL
> pointer for the temperature and this can be dereferenced in this function
> if the mlxsw_reg_query call fails.  The simplist fix is to pass the
> address of dummy temperature variable instead of a NULL pointer.
> 
> Addresses-Coverity: ("Explicit null dereferenced")
> Fixes: 72a64c2fe9d8 ("mlxsw: thermal: Read module temperature thresholds using MTMP register")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Reviewed-by: Ido Schimmel <idosch@nvidia.com>

Thanks

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH][next] mlxsw: thermal: Fix null dereference of NULL temperature parameter
  2021-06-09 17:56 [PATCH][next] mlxsw: thermal: Fix null dereference of NULL temperature parameter Colin King
  2021-06-09 18:07 ` Ido Schimmel
@ 2021-06-09 22:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-06-09 22:40 UTC (permalink / raw)
  To: Colin King
  Cc: jiri, idosch, davem, kuba, c_mykolak, vadimp, netdev,
	kernel-janitors, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (refs/heads/master):

On Wed,  9 Jun 2021 18:56:57 +0100 you wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> The call to mlxsw_thermal_module_temp_and_thresholds_get passes a NULL
> pointer for the temperature and this can be dereferenced in this function
> if the mlxsw_reg_query call fails.  The simplist fix is to pass the
> address of dummy temperature variable instead of a NULL pointer.
> 
> [...]

Here is the summary with links:
  - [next] mlxsw: thermal: Fix null dereference of NULL temperature parameter
    https://git.kernel.org/netdev/net-next/c/f3b5a8907543

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-09 22:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-09 17:56 [PATCH][next] mlxsw: thermal: Fix null dereference of NULL temperature parameter Colin King
2021-06-09 18:07 ` Ido Schimmel
2021-06-09 22:40 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.