phy: phy-exynos-mipi-video: Add sentinel element in match array
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 1 Sep 2015 07:51:56 +0000 (16:51 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Wed, 14 Dec 2016 04:47:58 +0000 (13:47 +0900)
This patch adds sentinel element in match array to fix following
out of bounds access:
    ==================================================================
    BUG: KASan: out of bounds access in __of_match_node+0x38/0xb8 at addr ffffffc001024010
    Read of size 1 by task swapper/0/1
    page:ffffffbdc0840900 count:1 mapcount:0 mapping:          (null) index:0x0
    flags: 0x400(reserved)
    page dumped because: kasan: bad access detected
    Address belongs to variable exynos_mipi_video_phy_of_match+0x190/0x3c0
    CPU: 5 PID: 1 Comm: swapper/0 Not tainted 4.1.0-00839-gb91c2a6-dirty #3
    Hardware name: Samsung TM2 board (DT)
    Call trace:
    [<ffffffc00008bc58>] dump_backtrace+0x0/0x1d8
    [<ffffffc00008be40>] show_stack+0x10/0x20
    [<ffffffc000eee3a4>] dump_stack+0x80/0xd4
    [<ffffffc00021e4f0>] kasan_report_error+0x3e0/0x408
    [<ffffffc00021e9ec>] kasan_report+0x44/0x50
    [<ffffffc00021d8f0>] __asan_load1+0x78/0x80
    [<ffffffc000a5aaa4>] __of_match_node+0x34/0xb8
    [<ffffffc000a5ab5c>] of_match_node+0x34/0x60
    [<ffffffc000a5d2cc>] of_match_device+0x2c/0x50
    [<ffffffc0006dcd58>] platform_match+0x68/0x130
    [<ffffffc0006d9d54>] __driver_attach+0x3c/0xd0
    [<ffffffc0006d6fac>] bus_for_each_dev+0xd4/0x138
    [<ffffffc0006d932c>] driver_attach+0x2c/0x40
    [<ffffffc0006d8dfc>] bus_add_driver+0x214/0x2e8
    [<ffffffc0006dab40>] driver_register+0xb0/0x1c0
    [<ffffffc0006dc618>] __platform_driver_register+0xa8/0xb8
    [<ffffffc0017855f4>] exynos_mipi_video_phy_driver_init+0x14/0x20
    [<ffffffc000082ae4>] do_one_initcall+0xec/0x240
    [<ffffffc001755e50>] kernel_init_freeable+0x288/0x330
    [<ffffffc000eeab1c>] kernel_init+0xc/0xf0
    Memory state around the buggy address:
     ffffffc001023f00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
     ffffffc001023f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
    >ffffffc001024000: 00 00 fa fa fa fa fa fa 00 00 00 fa fa fa fa fa
                             ^
     ffffffc001024080: 00 00 00 fa fa fa fa fa 00 00 00 01 fa fa fa fa
     ffffffc001024100: 00 00 06 fa fa fa fa fa 00 00 03 fa fa fa fa fa
    ==================================================================

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
drivers/phy/phy-exynos-mipi-video.c

index 6dad015..e62e81c 100644 (file)
@@ -261,6 +261,7 @@ static const struct of_device_id exynos_mipi_video_phy_of_match[] = {
                .compatible = "samsung,exynos5433-mipi-video-phy",
                .data = &exynos5433_mipi_phy,
        },
+       { /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, exynos_mipi_video_phy_of_match);