Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

platform/mellanox: mlxbf-pmc: fix sscanf() error checking

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>

authored by

Dan Carpenter and committed by
Hans de Goede
95e4b251 b54147fa

+2 -3
+2 -3
drivers/platform/mellanox/mlxbf-pmc.c
··· 1348 1348 1349 1349 for (i = 0; i < pmc->total_blocks; ++i) { 1350 1350 if (strstr(pmc->block_name[i], "tile")) { 1351 - ret = sscanf(pmc->block_name[i], "tile%d", &tile_num); 1352 - if (ret < 0) 1353 - return ret; 1351 + if (sscanf(pmc->block_name[i], "tile%d", &tile_num) != 1) 1352 + return -EINVAL; 1354 1353 1355 1354 if (tile_num >= pmc->tile_count) 1356 1355 continue;