All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: "monios114514@outlook.com" <monios114514@outlook.com>,
	"mingo@redhat.com" <mingo@redhat.com>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
	"peterz@infradead.org" <peterz@infradead.org>,
	"juri.lelli@redhat.com" <juri.lelli@redhat.com>,
	"vincent.guittot@linaro.org" <vincent.guittot@linaro.org>,
	"dietmar.eggemann@arm.com" <dietmar.eggemann@arm.com>,
	"rostedt@goodmis.org" <rostedt@goodmis.org>,
	"bsegall@google.com" <bsegall@google.com>,
	"mgorman@suse.de" <mgorman@suse.de>,
	"vschneid@redhat.com" <vschneid@redhat.com>,
	"kprateek.nayak@amd.com" <kprateek.nayak@amd.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sched/topology: fix memory leaks in allocation failure paths
Date: Fri, 14 Aug 2026 21:56:07 +0800	[thread overview]
Message-ID: <202608142104.E7fmtysw-lkp@intel.com> (raw)
In-Reply-To: <SL2P216MB261965EB5BCCF15723D13A76C1FE2@SL2P216MB2619.KORP216.PROD.OUTLOOK.COM>

Hi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tip/sched/core]
[also build test WARNING on peterz-queue/sched/core linus/master v7.2-rc7 next-20260813]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/monios114514-outlook-com/sched-topology-fix-memory-leaks-in-allocation-failure-paths/20260813-171714
base:   tip/sched/core
patch link:    https://lore.kernel.org/r/SL2P216MB261965EB5BCCF15723D13A76C1FE2%40SL2P216MB2619.KORP216.PROD.OUTLOOK.COM
patch subject: [PATCH] sched/topology: fix memory leaks in allocation failure paths
config: riscv-randconfig-002-20260814 (https://download.01.org/0day-ci/archive/20260814/202608142104.E7fmtysw-lkp@intel.com/config)
compiler: clang version 24.0.0git (https://github.com/llvm/llvm-project 844a18e753e822736c9805ab779144b647a2c186)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260814/202608142104.E7fmtysw-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202608142104.E7fmtysw-lkp@intel.com/

All warnings (new ones prefixed by >>):

   In file included from kernel/sched/build_utility.c:86:
>> kernel/sched/topology.c:2364:12: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
    2364 |                                 for (i = i; i >= 0; i--) {
         |                                      ~ ^ ~
   1 warning generated.


vim +/int +2364 kernel/sched/topology.c

  2310	
  2311	void sched_init_numa(int offline_node)
  2312	{
  2313		struct sched_domain_topology_level *tl;
  2314		int nr_levels, nr_node_levels;
  2315		int i, j;
  2316		int *distances, *domain_distances;
  2317		struct cpumask ***masks;
  2318	
  2319		if (sched_record_numa_dist(offline_node, numa_node_dist, &distances,
  2320					   &nr_node_levels))
  2321			return;
  2322	
  2323		if (modified_sched_node_distance()) {
  2324			if (sched_record_numa_dist(offline_node, arch_sched_node_distance,
  2325						   &domain_distances, &nr_levels)) {
  2326				kfree(distances);
  2327				return;
  2328			}
  2329		} else {
  2330			domain_distances = distances;
  2331			nr_levels = nr_node_levels;
  2332		}
  2333		rcu_assign_pointer(sched_numa_node_distance, distances);
  2334		WRITE_ONCE(sched_max_numa_distance, distances[nr_node_levels - 1]);
  2335		WRITE_ONCE(sched_numa_node_levels, nr_node_levels);
  2336	
  2337		rcu_assign_pointer(sched_domains_numa_distance, domain_distances);
  2338	
  2339		sched_domains_numa_levels = 0;
  2340	
  2341		masks = kzalloc(sizeof(void *) * nr_levels, GFP_KERNEL);
  2342		if (!masks)
  2343			goto free_distance;
  2344	
  2345		for (i = 0; i < nr_levels; i++) {
  2346			masks[i] = kzalloc(nr_node_ids * sizeof(void *), GFP_KERNEL);
  2347			if (!masks[i]) {
  2348				for (i = i - 1; i >= 0; i--) {
  2349					if (!masks[i])
  2350						continue;
  2351					for_each_cpu_node_but(j, offline_node)
  2352						kfree(masks[i][j]);
  2353					kfree(masks[i]);
  2354				}
  2355				kfree(masks);
  2356				goto free_distance;
  2357			}
  2358	
  2359			for_each_cpu_node_but(j, offline_node) {
  2360				struct cpumask *mask = kzalloc(cpumask_size(), GFP_KERNEL);
  2361				int k;
  2362	
  2363				if (!mask) {
> 2364					for (i = i; i >= 0; i--) {
  2365						if (!masks[i])
  2366							continue;
  2367						for_each_cpu_node_but(j, offline_node)
  2368							kfree(masks[i][j]);
  2369						kfree(masks[i]);
  2370					}
  2371					kfree(masks);
  2372					goto free_distance;
  2373				}
  2374	
  2375				masks[i][j] = mask;
  2376	
  2377				for_each_cpu_node_but(k, offline_node) {
  2378					if (sched_debug() &&
  2379					    (arch_sched_node_distance(j, k) !=
  2380					     arch_sched_node_distance(k, j)))
  2381						sched_numa_warn("Node-distance not symmetric");
  2382	
  2383					if (arch_sched_node_distance(j, k) >
  2384					    sched_domains_numa_distance[i])
  2385						continue;
  2386	
  2387					cpumask_or(mask, mask, cpumask_of_node(k));
  2388				}
  2389			}
  2390		}
  2391		rcu_assign_pointer(sched_domains_numa_masks, masks);
  2392	
  2393		for (i = 0; sched_domain_topology[i].mask; i++);
  2394	
  2395		tl = kzalloc((i + nr_levels + 1) *
  2396				sizeof(struct sched_domain_topology_level), GFP_KERNEL);
  2397		if (!tl) {
  2398			rcu_assign_pointer(sched_domains_numa_masks, NULL);
  2399			for (i = nr_levels - 1; i >= 0; i--) {
  2400				if (!masks[i])
  2401					continue;
  2402				for_each_cpu_node_but(j, offline_node)
  2403					kfree(masks[i][j]);
  2404				kfree(masks[i]);
  2405			}
  2406			kfree(masks);
  2407			goto free_distance;
  2408		}
  2409	
  2410		for (i = 0; sched_domain_topology[i].mask; i++)
  2411			tl[i] = sched_domain_topology[i];
  2412	
  2413		tl[i++] = SDTL_INIT(sd_numa_mask, NULL, NODE);
  2414	
  2415		for (j = 1; j < nr_levels; i++, j++) {
  2416			tl[i] = SDTL_INIT(sd_numa_mask, cpu_numa_flags, NUMA);
  2417			tl[i].numa_level = j;
  2418		}
  2419	
  2420		sched_domain_topology_saved = sched_domain_topology;
  2421		sched_domain_topology = tl;
  2422	
  2423		sched_domains_numa_levels = nr_levels;
  2424	
  2425		init_numa_topology_type(offline_node);
  2426		return;
  2427	
  2428	free_distance:
  2429		if (domain_distances != distances)
  2430			kfree(domain_distances);
  2431	}
  2432	

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

      reply	other threads:[~2026-08-14 13:57 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-09 23:03 [PATCH] sched/topology: fix memory leaks in allocation failure paths monios114514
2026-08-14 13:56 ` kernel test robot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202608142104.E7fmtysw-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=bsegall@google.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=juri.lelli@redhat.com \
    --cc=kprateek.nayak@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=monios114514@outlook.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=vincent.guittot@linaro.org \
    --cc=vschneid@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.