!2330 Add a check of uvhub_mask in init_per_cpu()
Merge Pull Request from: @amon-s1eepy Hello, I am Zheng Haoran from School of Cyber Science and Technology in Beihang University. I find a possible bug, using a program analysis tool named BassCheck developed by our team. In init_per_cpu(), uvhub_mask is allocated using kzalloc(GFP_KERNEL), which can fail and return NULL. Then uvhub_mask is used in the call to get_cpu_topology(uvhub_mask). In this function, uvhub_mask is used in the following code: ``` *(uvhub_mask + (uvhub/8)) |= (1 << (uvhub%8)); ``` Thus, a null-pointer dereference can occur to crash the kernel. To fix this possible bug, uvhub_mask should be checked after the call to kzalloc(GFP_KERNEL). Link:https://gitee.com/openeuler/kernel/pulls/2330 Reviewed-by:Wei Li <liwei391@huawei.com> Signed-off-by:
Zhang Changzhong <zhangchangzhong@huawei.com>
Loading
Please sign in to comment