Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e78bb5dc2e0515dce2ac2c590d66405028b7ccd6
Commit:     e78bb5dc2e0515dce2ac2c590d66405028b7ccd6
Parent:     750d1d1ca1d2e94e15393927fd3c30222d1c5203
Author:     Guennadi Liakhovetski <[EMAIL PROTECTED]>
AuthorDate: Thu Aug 16 05:15:03 2007 +1000
Committer:  Paul Mackerras <[EMAIL PROTECTED]>
CommitDate: Fri Aug 17 11:02:06 2007 +1000

    [POWERPC] Fix i2c device string format
    
    Use strlcpy() to guarantee strings in i2c device type and driver_name
    fields are 0-terminated.
    
    Signed-off-by: Guennadi Liakhovetski <[EMAIL PROTECTED]>
    Signed-off-by: Paul Mackerras <[EMAIL PROTECTED]>
---
 arch/powerpc/sysdev/fsl_soc.c |   13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 727453d..565f57d 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -320,21 +320,26 @@ static struct i2c_driver_device i2c_devices[] __initdata 
= {
        {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",},
 };
 
-static int __init of_find_i2c_driver(struct device_node *node, struct 
i2c_board_info *info)
+static int __init of_find_i2c_driver(struct device_node *node,
+                                    struct i2c_board_info *info)
 {
        int i;
 
        for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
                if (!of_device_is_compatible(node, i2c_devices[i].of_device))
                        continue;
-               strncpy(info->driver_name, i2c_devices[i].i2c_driver, 
KOBJ_NAME_LEN);
-               strncpy(info->type, i2c_devices[i].i2c_type, I2C_NAME_SIZE);
+               if (strlcpy(info->driver_name, i2c_devices[i].i2c_driver,
+                           KOBJ_NAME_LEN) >= KOBJ_NAME_LEN ||
+                   strlcpy(info->type, i2c_devices[i].i2c_type,
+                           I2C_NAME_SIZE) >= I2C_NAME_SIZE)
+                       return -ENOMEM;
                return 0;
        }
        return -ENODEV;
 }
 
-static void __init of_register_i2c_devices(struct device_node *adap_node, int 
bus_num)
+static void __init of_register_i2c_devices(struct device_node *adap_node,
+                                          int bus_num)
 {
        struct device_node *node = NULL;
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to