mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: John Madieu <john.madieu.xa@bp.renesas.com>
To: john.madieu.xa@bp.renesas.com
Cc: biju.das.jz@bp.renesas.com, claudiu.beznea.uj@bp.renesas.com,
	conor+dt@kernel.org, devicetree@vger.kernel.org,
	geert+renesas@glider.be, john.madieu@gmail.com,
	krzk+dt@kernel.org, linux-kernel@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org, magnus.damm@gmail.com,
	robh@kernel.org
Subject: [PATCH v2 2/4] soc: renesas: rz-sysc: Fix SoC ID string extraction
Date: Wed,  1 Jan 2025 17:33:42 +0100	[thread overview]
Message-ID: <20250101163344.128139-3-john.madieu.xa@bp.renesas.com> (raw)
In-Reply-To: <20250101163344.128139-1-john.madieu.xa@bp.renesas.com>

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@bp.renesas.com>
---
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


  parent reply	other threads:[~2025-01-01 16:39 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-06 21:25 [PATCH 0/5] soc: renesas: Add system controller support for RZ/G3E SoC John Madieu
2024-12-06 21:25 ` [PATCH 1/5] dt-bindings: arm: renesas: Add syscon compatibility to RZ/V2H(P) SYS Controller John Madieu
2024-12-06 21:25 ` [PATCH 2/5] dt-bindings: soc: renesas: Document Renesas RZ/G3E SoC variants John Madieu
2024-12-10 21:55   ` Rob Herring
2024-12-12 18:54     ` John Madieu
2024-12-13 16:06   ` Geert Uytterhoeven
2024-12-14  4:05     ` John Madieu
2024-12-06 21:25 ` [PATCH 3/5] soc: renesas: rz-sysc: Add support for RZ/G3E family John Madieu
2024-12-07 10:21   ` Claudiu Beznea
2024-12-09 11:30     ` John Madieu
2024-12-07 10:29   ` Biju Das
2024-12-09 10:44     ` John Madieu
2024-12-07 10:36   ` Biju Das
2024-12-09 10:43     ` John Madieu
2024-12-13 16:24   ` Geert Uytterhoeven
2024-12-14  4:36     ` John Madieu
2024-12-16  9:03       ` Geert Uytterhoeven
2024-12-06 21:25 ` [PATCH 4/5] arm64: dts: renesas: r9a09g047: add sys node John Madieu
2024-12-13 16:30   ` Geert Uytterhoeven
2024-12-06 21:25 ` [PATCH 5/5] arm64: dts: renesas: r9a09g057: Add syscon compatibility to " John Madieu
2024-12-11 21:08 ` [PATCH 0/5] soc: renesas: Add system controller support for RZ/G3E SoC Rob Herring
2024-12-13 15:50   ` Geert Uytterhoeven
2024-12-13 16:25 ` Geert Uytterhoeven
2024-12-14  4:49   ` John Madieu
2025-01-01 16:33 ` [PATCH v2 0/4] " John Madieu
2025-01-01 16:33   ` [PATCH v2 1/4] dt-bindings: soc: renesas: Add RZ/G3E variant SYS bindings John Madieu
2025-01-03 19:06     ` Rob Herring (Arm)
2025-01-01 16:33   ` John Madieu [this message]
2025-01-02 20:14     ` [PATCH v2 2/4] soc: renesas: rz-sysc: Fix SoC ID string extraction Geert Uytterhoeven
2025-01-01 16:33   ` [PATCH v2 3/4] soc: renesas: rz-sysc: Add support for RZ/G3E family John Madieu
2025-01-01 16:33   ` [PATCH v2 4/4] arm64: dts: renesas: r9a09g047: add sys node John Madieu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250101163344.128139-3-john.madieu.xa@bp.renesas.com \
    --to=john.madieu.xa@bp.renesas.com \
    --cc=biju.das.jz@bp.renesas.com \
    --cc=claudiu.beznea.uj@bp.renesas.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=john.madieu@gmail.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®