diff mbox series

[next] mlxsw: thermal: Fix null dereference of NULL temperature parameter

Message ID 20210609175657.299112-1-colin.king@canonical.com (mailing list archive)
State Accepted
Commit f3b5a8907543e2c539d09d01a1732826e070d351
Delegated to: Netdev Maintainers
Headers show
Series [next] mlxsw: thermal: Fix null dereference of NULL temperature parameter | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: line length of 85 exceeds 80 columns
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Colin King June 9, 2021, 5:56 p.m. UTC
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(-)

Comments

Ido Schimmel June 9, 2021, 6:07 p.m. UTC | #1
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
patchwork-bot+netdevbpf@kernel.org June 9, 2021, 10:40 p.m. UTC | #2
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
diff mbox series

Patch

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,