Unverified Commit f8c13117 authored by Shravan Kumar Ramani's avatar Shravan Kumar Ramani Committed by Ilpo Järvinen
Browse files

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: 423c3361 ("platform/mellanox: mlxbf-pmc: Add support for BlueField-3")
Signed-off-by: default avatarShravan Kumar Ramani <shravankr@nvidia.com>
Reviewed-by: default avatarDavid Thompson <davthompson@nvidia.com>
Link: https://lore.kernel.org/r/2ee618c59976bcf1379d5ddce2fc60ab5014b3a9.1751380187.git.shravankr@nvidia.com


[ij: split kstrbool() change to own commit.]
Reviewed-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: default avatarIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
parent 44e6ca8f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1223,7 +1223,7 @@ static int mlxbf_pmc_get_event_num(const char *blk, const char *evt)
	return -ENODEV;
}

/* Get the event number given the name */
/* Get the event name given the number */
static char *mlxbf_pmc_get_event_name(const char *blk, u32 evt)
{
	const struct mlxbf_pmc_events *events;
@@ -1807,6 +1807,9 @@ static ssize_t mlxbf_pmc_event_store(struct device *dev,
		err = kstrtouint(buf, 0, &evt_num);
		if (err < 0)
			return err;

		if (!mlxbf_pmc_get_event_name(pmc->block_name[blk_num], evt_num))
			return -EINVAL;
	}

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