diff options
author | Dan Carpenter <dan.carpenter@linaro.org> | 2023-05-15 13:32:37 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-05-30 14:03:32 +0100 |
commit | 47b4f741a3f6ecf61912e9447cf47f95c750d3ae (patch) | |
tree | 62e669f464d19cba96a098a1f0704717b86c2dbf | |
parent | 04238c23853a2f1ebb5cec9d2474d109d150e8ae (diff) | |
download | linux-stable-47b4f741a3f6ecf61912e9447cf47f95c750d3ae.tar.gz linux-stable-47b4f741a3f6ecf61912e9447cf47f95c750d3ae.tar.bz2 linux-stable-47b4f741a3f6ecf61912e9447cf47f95c750d3ae.zip |
platform/mellanox: mlxbf-pmc: fix sscanf() error checking
commit 95e4b25192e9238fd2dbe85d96dd2f8fd1ce9d14 upstream.
The sscanf() function never returns negatives. It returns the number of
items successfully read.
Fixes: 1a218d312e65 ("platform/mellanox: mlxbf-pmc: Add Mellanox BlueField PMC driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/4ccdfd28-099b-40bf-8d77-ad4ea2e76b93@kili.mountain
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/platform/mellanox/mlxbf-pmc.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c index c2c9b0d3244c..be967d797c28 100644 --- a/drivers/platform/mellanox/mlxbf-pmc.c +++ b/drivers/platform/mellanox/mlxbf-pmc.c @@ -1348,9 +1348,8 @@ static int mlxbf_pmc_map_counters(struct device *dev) for (i = 0; i < pmc->total_blocks; ++i) { if (strstr(pmc->block_name[i], "tile")) { - ret = sscanf(pmc->block_name[i], "tile%d", &tile_num); - if (ret < 0) - return ret; + if (sscanf(pmc->block_name[i], "tile%d", &tile_num) != 1) + return -EINVAL; if (tile_num >= pmc->tile_count) continue; |