|
Message-ID: <ieLySO0wXjkbKYOTqu2fRbPKXUdAB6xw5zDQedqQEpBKTD4t61myv42eN9b14T6nmoBd6lb45oK5_2rQ9mYKrNCTs76PrDVpLjk8CFf95E0=@ethancedwards.com> Date: Wed, 25 Dec 2024 00:11:55 +0000 From: Ethan Carter Edwards <ethan@...ancedwards.com> To: "mingo@...hat.com" <mingo@...hat.com> Cc: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, "linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>, "kernel-hardening@...ts.openwall.com" <kernel-hardening@...ts.openwall.com>, "bsegall@...gle.com" <bsegall@...gle.com>, "peterz@...radead.org" <peterz@...radead.org> Subject: [PATCH] sched/topology: change kzalloc to kcalloc We are replacing any instances of kzalloc(size * count, ...) with kcalloc(count, size, ...) due to risk of overflow [1]. [1] https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Ethan Carter Edwards <ethan@...ancedwards.com> --- kernel/sched/topology.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 9748a4c8d668..17eb12819563 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c @@ -1920,7 +1920,7 @@ void sched_init_numa(int offline_node) */ sched_domains_numa_levels = 0; - masks = kzalloc(sizeof(void *) * nr_levels, GFP_KERNEL); + masks = kcalloc(nr_levels, sizeof(void *), GFP_KERNEL); if (!masks) return; @@ -1929,7 +1929,7 @@ void sched_init_numa(int offline_node) * CPUs of nodes that are that many hops away from us. */ for (i = 0; i < nr_levels; i++) { - masks[i] = kzalloc(nr_node_ids * sizeof(void *), GFP_KERNEL); + masks[i] = kcalloc(nr_node_ids, sizeof(void *), GFP_KERNEL); if (!masks[i]) return; -- 2.47.1
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.