mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 20:10:23 +09:00
platform/mellanox: mlxbf-pmc: fix sscanf() error checking
commit95e4b25192upstream. The sscanf() function never returns negatives. It returns the number of items successfully read. Fixes:1a218d312e("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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d5ab5447d9
commit
fdf8f33e7d
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user