aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/sysdev
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2007-08-15 15:15:03 -0400
committerPaul Mackerras <paulus@samba.org>2007-08-16 21:02:06 -0400
commite78bb5dc2e0515dce2ac2c590d66405028b7ccd6 (patch)
tree1ffd3fcfec0cd2bc36398f8052900fca851b30b9 /arch/powerpc/sysdev
parent750d1d1ca1d2e94e15393927fd3c30222d1c5203 (diff)
[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 <g.liakhovetski@gmx.de> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/sysdev')
-rw-r--r--arch/powerpc/sysdev/fsl_soc.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 727453d3e8b9..565f57d777fe 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 = {
320 {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",}, 320 {"ricoh,rv5c387a", "rtc-rs5c372", "rv5c387a",},
321}; 321};
322 322
323static int __init of_find_i2c_driver(struct device_node *node, struct i2c_board_info *info) 323static int __init of_find_i2c_driver(struct device_node *node,
324 struct i2c_board_info *info)
324{ 325{
325 int i; 326 int i;
326 327
327 for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) { 328 for (i = 0; i < ARRAY_SIZE(i2c_devices); i++) {
328 if (!of_device_is_compatible(node, i2c_devices[i].of_device)) 329 if (!of_device_is_compatible(node, i2c_devices[i].of_device))
329 continue; 330 continue;
330 strncpy(info->driver_name, i2c_devices[i].i2c_driver, KOBJ_NAME_LEN); 331 if (strlcpy(info->driver_name, i2c_devices[i].i2c_driver,
331 strncpy(info->type, i2c_devices[i].i2c_type, I2C_NAME_SIZE); 332 KOBJ_NAME_LEN) >= KOBJ_NAME_LEN ||
333 strlcpy(info->type, i2c_devices[i].i2c_type,
334 I2C_NAME_SIZE) >= I2C_NAME_SIZE)
335 return -ENOMEM;
332 return 0; 336 return 0;
333 } 337 }
334 return -ENODEV; 338 return -ENODEV;
335} 339}
336 340
337static void __init of_register_i2c_devices(struct device_node *adap_node, int bus_num) 341static void __init of_register_i2c_devices(struct device_node *adap_node,
342 int bus_num)
338{ 343{
339 struct device_node *node = NULL; 344 struct device_node *node = NULL;
340 345