diff mbox series

powerpc/pasemi: Use strscpy instead of strlcpy

Message ID 20220827063946.9073-1-ruscur@russell.cc (mailing list archive)
State Accepted
Headers show
Series powerpc/pasemi: Use strscpy instead of strlcpy | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 10 jobs.
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 10 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 23 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 6 jobs.

Commit Message

Russell Currey Aug. 27, 2022, 6:39 a.m. UTC
find_i2c_driver() contained the last usage of strlcpy() in arch/powerpc.
The return value was used to check if strlen(src) >= n, for which
strscpy() returns -E2BIG.

Signed-off-by: Russell Currey <ruscur@russell.cc>
---
 arch/powerpc/platforms/pasemi/misc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Michael Ellerman Sept. 9, 2022, 12:07 p.m. UTC | #1
On Sat, 27 Aug 2022 16:39:46 +1000, Russell Currey wrote:
> find_i2c_driver() contained the last usage of strlcpy() in arch/powerpc.
> The return value was used to check if strlen(src) >= n, for which
> strscpy() returns -E2BIG.
> 
> 

Applied to powerpc/next.

[1/1] powerpc/pasemi: Use strscpy instead of strlcpy
      https://git.kernel.org/powerpc/c/245685495bff35062a394f5cdbd32b237dc596a5

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/platforms/pasemi/misc.c b/arch/powerpc/platforms/pasemi/misc.c
index f859ada29074..9e9a7e46288a 100644
--- a/arch/powerpc/platforms/pasemi/misc.c
+++ b/arch/powerpc/platforms/pasemi/misc.c
@@ -36,8 +36,7 @@  static int __init find_i2c_driver(struct device_node *node,
 	for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
 		if (!of_device_is_compatible(node, i2c_devices[i].of_device))
 			continue;
-		if (strlcpy(info->type, i2c_devices[i].i2c_type,
-			    I2C_NAME_SIZE) >= I2C_NAME_SIZE)
+		if (strscpy(info->type, i2c_devices[i].i2c_type, I2C_NAME_SIZE) < 0)
 			return -ENOMEM;
 		return 0;
 	}