dm table: Avoid null pointer dereference

Test: vts_libdm_test

Unable to handle kernel access to user memory outside uaccess routines
at virtual address 0000000000000018
[   83.108561] Mem abort info:
[   83.108896]   ESR = 0x96000005
[   83.109191]   Exception class = DABT (current EL), IL = 32 bits
[   83.110203]   SET = 0, FnV = 0
[   83.110505]   EA = 0, S1PTW = 0
[   83.110894] Data abort info:
[   83.111182]   ISV = 0, ISS = 0x00000005
[   83.111537]   CM = 0, WnR = 0
[   83.111929] user pgtable: 4k pages, 39-bit VAs, pgdp = 00000000cff2854e
[   83.112534] [0000000000000018] pgd=0000000033f28003, pud=0000000033f28003, pmd=0000000000000000
[   83.113403] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[   83.113912] Modules linked in: 8723cs
[   83.114257] Process vts_libdm_test (pid: 1985, stack limit = 0x000000007ea1bacc)
[   83.114923] CPU: 3 PID: 1985 Comm: vts_libdm_test Not tainted 4.19.154 #41
[   83.115534] Hardware name: Rockchip rk3326 863 rkisp1 board (DT)
[   83.116082] pstate: 40400005 (nZcv daif +PAN -UAO)
[   83.116534] pc : __pi_strncmp+0x24/0x208
[   83.116908] lr : dm_table_add_target+0x184/0x3bc
[   83.117326] sp : ffffff8012bcbb70

Fixes: 531fc5e280 ("dm: add check target device probe completely")
Signed-off-by: Bian Jin chen <kenjc.bian@rock-chips.com>
Change-Id: Icb943c4d1dfe116b3b39f4cd77b2eda232de65fe
This commit is contained in:
Bian Jin chen
2020-11-17 14:24:34 +08:00
committed by Tao Huang
parent 64e1eacb73
commit 0c17853c97

View File

@@ -788,7 +788,7 @@ int dm_table_add_target(struct dm_table *t, const char *type,
}
#ifdef CONFIG_ARCH_ROCKCHIP
while (argv &&
while (argv && (argc > 1) &&
strncmp(argv[1], "PARTUUID=", 9) == 0 &&
name_to_dev_t(argv[1]) == 0) {
DMINFO("%s: %s: Waiting for device %s ...",