LKML Archive on
help / color / mirror / Atom feed
From: Len Baker <>
To: Maxime Ripard <>, Chen-Yu Tsai <>,
	Jernej Skrabec <>
Cc: Len Baker <>,,,,
Subject: [PATCH] i2c: sun6i-pw2i: Prefer strscpy over strlcpy
Date: Tue, 17 Aug 2021 18:58:59 +0200	[thread overview]
Message-ID: <> (raw)

strlcpy() reads the entire source buffer first. This read may exceed the
destination size limit. This is both inefficient and can lead to linear
read overflows if a source string is not NUL-terminated. The safe
replacement is strscpy().

This is a previous step in the path to remove the strlcpy() function
entirely from the kernel [1].


Signed-off-by: Len Baker <>
 drivers/i2c/busses/i2c-sun6i-p2wi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c
index 2f6f6468214d..9e3483f507ff 100644
--- a/drivers/i2c/busses/i2c-sun6i-p2wi.c
+++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c
@@ -234,7 +234,7 @@ static int p2wi_probe(struct platform_device *pdev)
 	if (IS_ERR(p2wi->regs))
 		return PTR_ERR(p2wi->regs);

-	strlcpy(p2wi->, pdev->name, sizeof(p2wi->;
+	strscpy(p2wi->, pdev->name, sizeof(p2wi->;
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
 		return irq;

             reply	other threads:[~2021-08-17 16:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17 16:58 Len Baker [this message]
2021-08-17 19:36 ` Wolfram Sang

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:

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

  git send-email \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] i2c: sun6i-pw2i: Prefer strscpy over strlcpy' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).