Re: [PATCH] platform/mellanox: mlxbf-pmc: fix signedness bugs

From: Ilpo Järvinen
Date: Mon Mar 04 2024 - 08:23:04 EST


On Thu, 29 Feb 2024, Dan Carpenter wrote:

> These need to be signed for the error handling to work. The
> mlxbf_pmc_get_event_num() function returns int so int type is correct.
>
> Fixes: 1ae9ffd303c2 ("platform/mellanox: mlxbf-pmc: Cleanup signed/unsigned mix-up")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---
> The code in mlxbf_pmc_valid_range() has a check for negatives but that
> has a signedness bug too. Fortunately "(u32)-EINVAL + 8" will not
> result in an integer overflow so the offset is treated as invalid.

Hi,

While this patch itself was fine so I applied it, when reviewing the patch
I noticed that some of the kstrtouint() derived values were not properly
bound checked (some were fed directly to FIELD_PREP()).

--
i.