Bug 8872 - clk: Fix clk_core_get NULL dereference
Summary: clk: Fix clk_core_get NULL dereference
Status: RESOLVED FIXED
Alias: None
Product: ANCK 5.10 Dev
Classification: ANCK
Component: general/others (show other bugs) general/others
Version: unspecified
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: banye97
QA Contact: shuming
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-04-24 10:36 UTC by zhujun
Modified: 2024-09-23 17:44 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zhujun cmss_group 2024-04-24 10:36:33 UTC
It is possible for clk_core_get to dereference a NULL in the following
sequence:

clk_core_get()
    of_clk_get_hw_from_clkspec()
        __of_clk_get_hw_from_provider()
            __clk_get_hw()

__clk_get_hw() can return NULL which is dereferenced by clk_core_get() at
hw->core.

Prior to commit dde4eff47c82 ("clk: Look for parents with clkdev based
clk_lookups") the check IS_ERR_OR_NULL() was performed which would have
caught the NULL.

Reading the description of this function it talks about returning NULL but 
that cannot be so at the moment.

Update the function to check for hw before dereferencing it and return NULL
if hw is NULL.

社区有patch已经解决

clk: Fix clk_core_get NULL dereference

commit 239174535dba11f7b83de0eaaa27909024f8c185

Reference:https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-5.10.y&id=239174535dba11f7b83de0eaaa27909024f8c185

git cherry-pick -s 239174535(with stable-v5.10.215 repo added)
Comment 1 小龙 admin 2024-04-24 10:38:44 UTC
The PR Link: https://gitee.com/anolis/cloud-kernel/pulls/3091
Comment 2 小龙 admin 2024-08-13 13:58:07 UTC
The PR Link: https://gitee.com/anolis/cloud-kernel/pulls/3686
Comment 3 banye97 alibaba_cloud_group 2024-09-23 17:44:55 UTC
PR 已合入