Skip to content
/ linux Public

Commit f3b5a89

Browse files
Colin Ian Kingdavem330
authored andcommitted
mlxsw: thermal: Fix null dereference of NULL temperature parameter
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: 72a64c2 ("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> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8b8701d commit f3b5a89

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/net/ethernet/mellanox/mlxsw/core_thermal.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
742742
struct mlxsw_thermal *thermal, u8 module)
743743
{
744744
struct mlxsw_thermal_module *module_tz;
745-
int crit_temp, emerg_temp;
745+
int dummy_temp, crit_temp, emerg_temp;
746746
u16 sensor_index;
747747

748748
sensor_index = MLXSW_REG_MTMP_MODULE_INDEX_MIN + module;
@@ -757,7 +757,7 @@ mlxsw_thermal_module_init(struct device *dev, struct mlxsw_core *core,
757757
/* Initialize all trip point. */
758758
mlxsw_thermal_module_trips_reset(module_tz);
759759
/* Read module temperature and thresholds. */
760-
mlxsw_thermal_module_temp_and_thresholds_get(core, sensor_index, NULL,
760+
mlxsw_thermal_module_temp_and_thresholds_get(core, sensor_index, &dummy_temp,
761761
&crit_temp, &emerg_temp);
762762
/* Update trip point according to the module data. */
763763
return mlxsw_thermal_module_trips_update(dev, core, module_tz,

0 commit comments

Comments
 (0)