Skip to content

Commit b0dbe5f

Browse files
Sergey Shtylyovgregkh
authored andcommitted
of: cpu: add check in __of_find_n_match_cpu_property()
[ Upstream commit 5901eda ] In __of_find_n_match_cpu_property(), checking the variable ac for 0 won't prevent a possible overflow when multiplying it by sizeof(*cell). Besides, of_read_number() (called in the *for* loop) can't return correct result if that variable (which equals the #address-cells prop's value) exceeds 2, so additionally checking for that seems logical... Found by Linux Verification Center (linuxtesting.org) with the Svace static analysis tool. Fixes: f3cea45 ("of: Fix iteration bug over CPU reg properties") Signed-off-by: Sergey Shtylyov <s.shtylyov@auroraos.dev> Link: https://patch.msgid.link/0c7bf7e9-887c-42d5-bcfb-0ba7fe1e70b6@auroraos.dev Signed-off-by: Rob Herring (Arm) <robh@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7f10e0f commit b0dbe5f

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/of/cpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static bool __of_find_n_match_cpu_property(struct device_node *cpun,
6060
cell = of_get_property(cpun, prop_name, &prop_len);
6161
if (!cell && !ac && arch_match_cpu_phys_id(cpu, 0))
6262
return true;
63-
if (!cell || !ac)
63+
if (!cell || !ac || ac > 2)
6464
return false;
6565
prop_len /= sizeof(*cell) * ac;
6666
for (tid = 0; tid < prop_len; tid++) {

0 commit comments

Comments
 (0)