On Wed, Jan 10, 2024 at 08:07:54AM -0800, Andrew Morton wrote: > > The patch titled > Subject: lib/group_cpus: rework group_cpus_evenly() > has been added to the -mm mm-nonmm-unstable branch. Its filename is > lib-group_cpus-rework-group_cpus_evenly.patch > > This patch will shortly appear at > https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/lib-group_cpus-rework-group_cpus_evenly.patch > > This patch will later appear in the mm-nonmm-unstable branch at > git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm > > Before you just go and hit "reply", please: > a) Consider who else should be cc'ed > b) Prefer to cc a suitable mailing list as well > c) Ideally: find the original patch on the mailing list and do a > reply-to-all to that, adding suitable additional cc's > > *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** > > The -mm tree is included into linux-next via the mm-everything > branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm > and is updated there every 2-3 working days > > ------------------------------------------------------ > From: Yury Norov <yury.norov@xxxxxxxxx> > Subject: lib/group_cpus: rework group_cpus_evenly() > Date: Thu, 28 Dec 2023 12:09:35 -0800 > > Leverage cleanup machinery and drop most of housekeeping code. > Particularly, drop unneeded and erroneously initialized with -ENOMEM > variable ret. > > Link: https://lkml.kernel.org/r/20231228200936.2475595-9-yury.norov@xxxxxxxxx > Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx> > Cc: Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> > Cc: Ming Lei <ming.lei@xxxxxxxxxx> > Cc: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx> > Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Hi Andrew, Thanks for taking this series. I received a couple of 0-day reports on initialization section of the new group_cpus_evenly(), and wanted to send v5 shortly. Below is the patch fixing them. I think it should be fixed at the early stage. So, at your discretion, can you either meld the fix into this patch, apply it on top of the series, or I can send v5 with everything fixed. Thanks, Yury >From 5349b044f0a9e6a1816b786271c9c632a71edc38 Mon Sep 17 00:00:00 2001 From: Yury Norov <yury.norov@xxxxxxxxx> Date: Wed, 10 Jan 2024 09:46:39 -0800 Subject: [PATCH] lib/group_cpus: fix initialization section in group_cpus_evenly() _free() parameters have to be initialized at declaration to avoid passing uninitialized pointer to the destructor (unless such a parameter is initialized before any possibility of return). nr_present and nr_others are assigned by __group_cpus_evenly(), which may return negative value in case of error. So make it signed. Reported-by: kernel test robot <lkp@xxxxxxxxx> Closes: https://lore.kernel.org/oe-kbuild-all/202312310941.FXBRzn8C-lkp@xxxxxxxxx/ Reported-by: kernel test robot <lkp@xxxxxxxxx> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx> Closes: https://lore.kernel.org/r/202401050452.IcgrcQON-lkp@xxxxxxxxx/ Signed-off-by: Yury Norov <yury.norov@xxxxxxxxx> --- lib/group_cpus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/group_cpus.c b/lib/group_cpus.c index 3a0db0f51f09..c9c95b21e6c6 100644 --- a/lib/group_cpus.c +++ b/lib/group_cpus.c @@ -353,8 +353,8 @@ struct cpumask *group_cpus_evenly(unsigned int numgrps) { cpumask_var_t *node_to_cpumask __free(free_node_to_cpumask) = alloc_node_to_cpumask(); struct cpumask *masks __free(kfree) = kcalloc(numgrps, sizeof(*masks), GFP_KERNEL); - cpumask_var_t npresmsk __free(free_cpumask_var); - unsigned int curgrp, nr_present, nr_others; + cpumask_var_t npresmsk __free(free_cpumask_var) = NULL; + int curgrp, nr_present, nr_others; if (!masks || !node_to_cpumask || !alloc_cpumask_var(&npresmsk, GFP_KERNEL)) return NULL; -- 2.40.1