Commit d2059d3b authored by Viresh Kumar's avatar Viresh Kumar

cpufreq: sun50i: Fix build warning around snprint()

The Sun50i driver generates a warning with W=1:

warning: '%d' directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=]

Fix it by allocating a big enough array to print an integer.
Reported-by: default avatarkernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202404191715.LDwMm2gP-lkp@intel.com/Signed-off-by: default avatarViresh Kumar <viresh.kumar@linaro.org>
Acked-by: default avatarChen-Yu Tsai <wens@csie.org>
Reviewed-by: default avatarAndre Przywara <andre.przywara@arm.com>
Tested-by: default avatarAndre Przywara <andre.przywara@arm.com>
Reviewed-by: default avatarJulian Calaby <julian.calaby@gmail.com>
parent 09d0aaa0
......@@ -19,8 +19,6 @@
#include <linux/pm_opp.h>
#include <linux/slab.h>
#define MAX_NAME_LEN 7
#define NVMEM_MASK 0x7
#define NVMEM_SHIFT 5
......@@ -208,7 +206,7 @@ static int sun50i_cpufreq_get_efuse(void)
static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev)
{
int *opp_tokens;
char name[MAX_NAME_LEN];
char name[] = "speedXXXXXXXXXXX"; /* Integers can take 11 chars max */
unsigned int cpu, supported_hw;
struct dev_pm_opp_config config = {};
int speed;
......@@ -235,7 +233,7 @@ static int sun50i_cpufreq_nvmem_probe(struct platform_device *pdev)
config.supported_hw_count = 1;
}
snprintf(name, MAX_NAME_LEN, "speed%d", speed);
snprintf(name, sizeof(name), "speed%d", speed);
config.prop_name = name;
for_each_possible_cpu(cpu) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment