]> git.baikalelectronics.ru Git - kernel.git/commitdiff
powerpc/pasemi: Use strscpy instead of strlcpy
authorRussell Currey <ruscur@russell.cc>
Sat, 27 Aug 2022 06:39:46 +0000 (16:39 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 6 Sep 2022 01:03:04 +0000 (11:03 +1000)
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
arch/powerpc/platforms/pasemi/misc.c

index f859ada29074a31903a333e2e90babea31603441..9e9a7e46288a884554a1d21cb07c28daef186680 100644 (file)
@@ -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;
        }