Skip to content

Commit f8c1311

Browse files
shravankumarrij-intel
authored andcommitted
platform/mellanox: mlxbf-pmc: Validate event/enable input
Before programming the event info, validate the event number received as input by checking if it exists in the event_list. Also fix a typo in the comment for mlxbf_pmc_get_event_name() to correctly mention that it returns the event name when taking the event number as input, and not the other way round. Fixes: 423c336 ("platform/mellanox: mlxbf-pmc: Add support for BlueField-3") Signed-off-by: Shravan Kumar Ramani <[email protected]> Reviewed-by: David Thompson <[email protected]> Link: https://lore.kernel.org/r/2ee618c59976bcf1379d5ddce2fc60ab5014b3a9.1751380187.git.shravankr@nvidia.com [ij: split kstrbool() change to own commit.] Reviewed-by: Ilpo Järvinen <[email protected]> Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent 44e6ca8 commit f8c1311

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/platform/mellanox/mlxbf-pmc.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ static int mlxbf_pmc_get_event_num(const char *blk, const char *evt)
12231223
return -ENODEV;
12241224
}
12251225

1226-
/* Get the event number given the name */
1226+
/* Get the event name given the number */
12271227
static char *mlxbf_pmc_get_event_name(const char *blk, u32 evt)
12281228
{
12291229
const struct mlxbf_pmc_events *events;
@@ -1807,6 +1807,9 @@ static ssize_t mlxbf_pmc_event_store(struct device *dev,
18071807
err = kstrtouint(buf, 0, &evt_num);
18081808
if (err < 0)
18091809
return err;
1810+
1811+
if (!mlxbf_pmc_get_event_name(pmc->block_name[blk_num], evt_num))
1812+
return -EINVAL;
18101813
}
18111814

18121815
if (strstr(pmc->block_name[blk_num], "l3cache"))

0 commit comments

Comments
 (0)