mirror of
https://github.com/smaeul/u-boot.git
synced 2025-10-13 20:36:02 +01:00
cpu: microblaze: add error handling in microblaze_cpu_get_desc()
Check snprintf() return value for errors. Make microblaze_cpu_get_desc() directly return snprintf() error code if ret < 0. Otherwise, if the return value is greater than or equal to size, the resulting string is truncated, so return -ENOSPC. Fixes: 816226d27e ("cpu: add CPU driver for microblaze") Signed-off-by: Ovidiu Panait <ovpanait@gmail.com> Link: https://lore.kernel.org/r/20220829170205.1274484-2-ovpanait@gmail.com Signed-off-by: Michal Simek <michal.simek@amd.com>
This commit is contained in:
parent
3a6948ce71
commit
3f351cd358
@ -97,8 +97,10 @@ static int microblaze_cpu_get_desc(const struct udevice *dev, char *buf,
|
|||||||
ret = snprintf(buf, size,
|
ret = snprintf(buf, size,
|
||||||
"MicroBlaze @ %uMHz, Rev: %s, FPGA family: %s",
|
"MicroBlaze @ %uMHz, Rev: %s, FPGA family: %s",
|
||||||
cpu_freq_mhz, cpu_ver, fpga_family);
|
cpu_freq_mhz, cpu_ver, fpga_family);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
return 0;
|
return (ret >= size) ? -ENOSPC : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int microblaze_cpu_get_info(const struct udevice *dev,
|
static int microblaze_cpu_get_info(const struct udevice *dev,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user