diff options
author | Len Baker <len.baker@gmx.com> | 2021-08-08 14:50:11 +0200 |
---|---|---|
committer | Geert Uytterhoeven <geert+renesas@glider.be> | 2021-08-12 12:36:57 +0200 |
commit | 148bcca9ad0488d623aa36b21ac152bb056a1ae4 (patch) | |
tree | 5f1b5512f0506500396eaaffb277038c3a3a6b3c /drivers/soc/renesas/rcar-sysc.c | |
parent | bfe6b5590ce6cab81b3ee51b4541bd1d0b18b3b2 (diff) | |
download | linux-148bcca9ad0488d623aa36b21ac152bb056a1ae4.tar.gz linux-148bcca9ad0488d623aa36b21ac152bb056a1ae4.tar.bz2 linux-148bcca9ad0488d623aa36b21ac152bb056a1ae4.zip |
soc: renesas: Prefer memcpy() over strcpy()
strcpy() performs no bounds checking on the destination buffer. This
could result in linear overflows beyond the end of the buffer, leading
to all kinds of misbehaviors. So, use memcpy() as a safe replacement.
This is a previous step in the path to remove the strcpy() function
entirely from the kernel.
Signed-off-by: Len Baker <len.baker@gmx.com>
Link: https://lore.kernel.org/r/20210808125012.4715-3-len.baker@gmx.com
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Diffstat (limited to 'drivers/soc/renesas/rcar-sysc.c')
-rw-r--r-- | drivers/soc/renesas/rcar-sysc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/soc/renesas/rcar-sysc.c b/drivers/soc/renesas/rcar-sysc.c index 53387a72ca00..b0a80de34c98 100644 --- a/drivers/soc/renesas/rcar-sysc.c +++ b/drivers/soc/renesas/rcar-sysc.c @@ -396,19 +396,21 @@ static int __init rcar_sysc_pd_init(void) for (i = 0; i < info->num_areas; i++) { const struct rcar_sysc_area *area = &info->areas[i]; struct rcar_sysc_pd *pd; + size_t n; if (!area->name) { /* Skip NULLified area */ continue; } - pd = kzalloc(sizeof(*pd) + strlen(area->name) + 1, GFP_KERNEL); + n = strlen(area->name) + 1; + pd = kzalloc(sizeof(*pd) + n, GFP_KERNEL); if (!pd) { error = -ENOMEM; goto out_put; } - strcpy(pd->name, area->name); + memcpy(pd->name, area->name, n); pd->genpd.name = pd->name; pd->ch.chan_offs = area->chan_offs; pd->ch.chan_bit = area->chan_bit; |