From e2d506b7eaf3f6835603118d02bfcd9430138864 Mon Sep 17 00:00:00 2001 From: "Huang, Tao" Date: Thu, 7 Jul 2016 21:32:56 +0800 Subject: [PATCH] regulator: xz3216: Add a sentinel to xz3216_i2c_id[] This patch fix this bug: BUG: KASAN: global-out-of-bounds in i2c_device_match+0x64/0xa4 at addr ffffff9009046800 Read of size 1 by task swapper/0/1 Address belongs to variable xz3216_i2c_id+0x20/0x2c0 CPU: 5 PID: 1 Comm: swapper/0 Not tainted 4.4.14 #21 Hardware name: Rockchip RK3399 Evaluation Board v2 (Android) (DT) Call trace: [] dump_backtrace+0x0/0x288 [] show_stack+0x14/0x1c [] dump_stack+0xc4/0x100 [] kasan_report+0x36c/0x49c [] __asan_load1+0x24/0x50 [] i2c_device_match+0x64/0xa4 [] __device_attach_driver+0x80/0xd8 [] bus_for_each_drv+0xf8/0x12c [] __device_attach+0x114/0x1a4 [] device_initial_probe+0x10/0x18 [] bus_probe_device+0x50/0xe8 [] device_add+0x5f8/0x774 [] device_register+0x1c/0x28 [] i2c_new_device+0x258/0x2a4 [] i2c_register_adapter+0x4b4/0x600 [] __i2c_add_numbered_adapter+0x78/0x88 [] i2c_add_adapter+0x50/0xcc [] rk3x_i2c_probe+0x460/0x4fc [] platform_drv_probe+0x70/0xc8 [] driver_probe_device+0x16c/0x364 [] __driver_attach+0x94/0xc8 [] bus_for_each_dev+0xe0/0x11c [] driver_attach+0x30/0x3c [] bus_add_driver+0x160/0x294 [] driver_register+0x10c/0x168 [] __platform_driver_register+0x7c/0x88 [] rk3x_i2c_driver_init+0x18/0x20 [] do_one_initcall+0x168/0x220 [] kernel_init_freeable+0x1d0/0x274 [] kernel_init+0x10/0x108 [] ret_from_fork+0x10/0x40 Memory state around the buggy address: ffffff9009046700: fa fa fa fa 00 03 fa fa fa fa fa fa 00 00 00 07 ffffff9009046780: fa fa fa fa 07 fa fa fa fa fa fa fa 00 00 00 00 >ffffff9009046800: fa fa fa fa 00 01 fa fa fa fa fa fa 00 01 fa fa ^ ffffff9009046880: fa fa fa fa 04 fa fa fa fa fa fa fa 00 04 fa fa ffffff9009046900: fa fa fa fa 00 05 fa fa fa fa fa fa 07 fa fa fa Change-Id: I624d92b1fefdf87cfb58b9df10db85723b5ed534 Signed-off-by: Huang, Tao --- drivers/regulator/xz3216.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/regulator/xz3216.c b/drivers/regulator/xz3216.c index 4df9f4e2a489..3bcaf898c768 100644 --- a/drivers/regulator/xz3216.c +++ b/drivers/regulator/xz3216.c @@ -366,6 +366,7 @@ static int xz3216_i2c_remove(struct i2c_client *i2c) static const struct i2c_device_id xz3216_i2c_id[] = { { "xz3216", 0 }, + { } }; MODULE_DEVICE_TABLE(i2c, xz3216_i2c_id); -- 2.34.1