Fix string length calculation when extracting the SoC ID from the compatible string. Add +1 to the size calculation to ensure proper string termination when copying with strncpy(). This prevents potential string trunctation when processing the device tree compatible string to identify the SoC. Signed-off-by: John Madieu <john.madieu.xa@xxxxxxxxxxxxxx> --- New patch introduced in v2, targetting specific fix. drivers/soc/renesas/rz-sysc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/soc/renesas/rz-sysc.c b/drivers/soc/renesas/rz-sysc.c index d34d295831b8..e472fda3995b 100644 --- a/drivers/soc/renesas/rz-sysc.c +++ b/drivers/soc/renesas/rz-sysc.c @@ -231,7 +231,7 @@ static int rz_sysc_soc_init(struct rz_sysc *sysc, const struct of_device_id *mat soc_id_start = strchr(match->compatible, ',') + 1; soc_id_end = strchr(match->compatible, '-'); - size = soc_id_end - soc_id_start; + size = soc_id_end - soc_id_start + 1; if (size > 32) size = 32; strscpy(soc_id, soc_id_start, size); -- 2.25.1