Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/pasemi: Use strscpy instead of strlcpy

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>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220827063946.9073-1-ruscur@russell.cc

authored by

Russell Currey and committed by
Michael Ellerman
24568549 9b135eef

+1 -2
+1 -2
arch/powerpc/platforms/pasemi/misc.c
··· 36 36 for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) { 37 37 if (!of_device_is_compatible(node, i2c_devices[i].of_device)) 38 38 continue; 39 - if (strlcpy(info->type, i2c_devices[i].i2c_type, 40 - I2C_NAME_SIZE) >= I2C_NAME_SIZE) 39 + if (strscpy(info->type, i2c_devices[i].i2c_type, I2C_NAME_SIZE) < 0) 41 40 return -ENOMEM; 42 41 return 0; 43 42 }