oe-kbuild-all.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Lizhi Xu <lizhi.xu@windriver.com>,
	syzbot+006987d1be3586e13555@syzkaller.appspotmail.com
Cc: oe-kbuild-all@lists.linux.dev, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
	mani@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com,
	syzkaller-bugs@googlegroups.com
Subject: Re: [PATCH] radix-tree: fix memory leak in radix_tree_insert
Date: Tue, 12 Dec 2023 07:16:50 +0800	[thread overview]
Message-ID: <202312120651.92GGXeX4-lkp@intel.com> (raw)
In-Reply-To: <20231211094840.642118-1-lizhi.xu@windriver.com>

Hi Lizhi,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-nonmm-unstable]
[also build test WARNING on linus/master v6.7-rc5 next-20231211]
[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/Lizhi-Xu/radix-tree-fix-memory-leak-in-radix_tree_insert/20231211-174951
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-nonmm-unstable
patch link:    https://lore.kernel.org/r/20231211094840.642118-1-lizhi.xu%40windriver.com
patch subject: [PATCH] radix-tree: fix memory leak in radix_tree_insert
config: i386-randconfig-061-20231212 (https://download.01.org/0day-ci/archive/20231212/202312120651.92GGXeX4-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231212/202312120651.92GGXeX4-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/202312120651.92GGXeX4-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
   lib/radix-tree.c:266:36: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct xa_node *nodes @@     got struct xa_node [noderef] __rcu *parent @@
   lib/radix-tree.c:266:36: sparse:     expected struct xa_node *nodes
   lib/radix-tree.c:266:36: sparse:     got struct xa_node [noderef] __rcu *parent
   lib/radix-tree.c:284:29: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct xa_node [noderef] __rcu *parent @@     got struct xa_node *parent @@
   lib/radix-tree.c:284:29: sparse:     expected struct xa_node [noderef] __rcu *parent
   lib/radix-tree.c:284:29: sparse:     got struct xa_node *parent
   lib/radix-tree.c:344:38: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct xa_node [noderef] __rcu *parent @@     got struct xa_node *nodes @@
   lib/radix-tree.c:344:38: sparse:     expected struct xa_node [noderef] __rcu *parent
   lib/radix-tree.c:344:38: sparse:     got struct xa_node *nodes
   lib/radix-tree.c:446:54: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct xa_node [noderef] __rcu *parent @@     got struct xa_node *node @@
   lib/radix-tree.c:446:54: sparse:     expected struct xa_node [noderef] __rcu *parent
   lib/radix-tree.c:446:54: sparse:     got struct xa_node *node
   lib/radix-tree.c:558:24: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct xa_node *parent @@     got struct xa_node [noderef] __rcu *parent @@
   lib/radix-tree.c:558:24: sparse:     expected struct xa_node *parent
   lib/radix-tree.c:558:24: sparse:     got struct xa_node [noderef] __rcu *parent
>> lib/radix-tree.c:653:28: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct xa_node *pn @@     got struct xa_node [noderef] __rcu *parent @@
   lib/radix-tree.c:653:28: sparse:     expected struct xa_node *pn
   lib/radix-tree.c:653:28: sparse:     got struct xa_node [noderef] __rcu *parent
   lib/radix-tree.c:687:31: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct xa_node *[assigned] child @@     got struct xa_node [noderef] __rcu *parent @@
   lib/radix-tree.c:687:31: sparse:     expected struct xa_node *[assigned] child
   lib/radix-tree.c:687:31: sparse:     got struct xa_node [noderef] __rcu *parent
   lib/radix-tree.c:962:22: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct xa_node *node @@     got struct xa_node [noderef] __rcu *parent @@
   lib/radix-tree.c:962:22: sparse:     expected struct xa_node *node
   lib/radix-tree.c:962:22: sparse:     got struct xa_node [noderef] __rcu *parent
   lib/radix-tree.c:1022:22: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct xa_node *node @@     got struct xa_node [noderef] __rcu *parent @@
   lib/radix-tree.c:1022:22: sparse:     expected struct xa_node *node
   lib/radix-tree.c:1022:22: sparse:     got struct xa_node [noderef] __rcu *parent
   lib/radix-tree.c:1542:38: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct xa_node *[assigned] node @@     got struct xa_node [noderef] __rcu *parent @@
   lib/radix-tree.c:1542:38: sparse:     expected struct xa_node *[assigned] node
   lib/radix-tree.c:1542:38: sparse:     got struct xa_node [noderef] __rcu *parent
   lib/radix-tree.c:1602:28: sparse: sparse: incorrect type in assignment (different address spaces) @@     expected struct xa_node *nodes @@     got struct xa_node [noderef] __rcu *parent @@
   lib/radix-tree.c:1602:28: sparse:     expected struct xa_node *nodes
   lib/radix-tree.c:1602:28: sparse:     got struct xa_node [noderef] __rcu *parent

vim +653 lib/radix-tree.c

   581	
   582	/**
   583	 *	__radix_tree_create	-	create a slot in a radix tree
   584	 *	@root:		radix tree root
   585	 *	@index:		index key
   586	 *	@nodep:		returns node
   587	 *	@slotp:		returns slot
   588	 *
   589	 *	Create, if necessary, and return the node and slot for an item
   590	 *	at position @index in the radix tree @root.
   591	 *
   592	 *	Until there is more than one item in the tree, no nodes are
   593	 *	allocated and @root->xa_head is used as a direct slot instead of
   594	 *	pointing to a node, in which case *@nodep will be NULL.
   595	 *
   596	 *	Returns -ENOMEM, or 0 for success.
   597	 */
   598	static int __radix_tree_create(struct radix_tree_root *root,
   599			unsigned long index, struct radix_tree_node **nodep,
   600			void __rcu ***slotp)
   601	{
   602		struct radix_tree_node *node = NULL, *child;
   603		void __rcu **slot = (void __rcu **)&root->xa_head;
   604		unsigned long maxindex;
   605		unsigned int shift, offset = 0, mmshift = 0;
   606		unsigned long max = index;
   607		gfp_t gfp = root_gfp_mask(root);
   608		int ret;
   609	
   610		shift = radix_tree_load_root(root, &child, &maxindex);
   611	
   612		/* Make sure the tree is high enough.  */
   613		if (max > maxindex) {
   614			int error = radix_tree_extend(root, gfp, max, shift);
   615			if (error < 0)
   616				return error;
   617			shift = error;
   618			mmshift = error;
   619			child = rcu_dereference_raw(root->xa_head);
   620		}
   621	
   622		while (shift > 0) {
   623			shift -= RADIX_TREE_MAP_SHIFT;
   624			if (child == NULL) {
   625				/* Have to add a child node.  */
   626				child = radix_tree_node_alloc(gfp, node, root, shift,
   627								offset, 0, 0);
   628				if (!child) {
   629					 ret = -ENOMEM;
   630					 goto freec;
   631				}
   632				rcu_assign_pointer(*slot, node_to_entry(child));
   633				if (node)
   634					node->count++;
   635			} else if (!radix_tree_is_internal_node(child))
   636				break;
   637	
   638			/* Go a level down */
   639			node = entry_to_node(child);
   640			offset = radix_tree_descend(node, &child, index);
   641			slot = &node->slots[offset];
   642		}
   643	
   644		if (nodep)
   645			*nodep = node;
   646		if (slotp)
   647			*slotp = slot;
   648		return 0;
   649	freec:
   650		if (mmshift > 0) {
   651			struct radix_tree_node *pn;
   652			while (shift < mmshift && node) {
 > 653				pn = node->parent;
   654				radix_tree_node_rcu_free(&node->rcu_head);
   655				shift += RADIX_TREE_MAP_SHIFT;
   656				node = pn;
   657			}
   658		}
   659		return ret;
   660	}
   661	

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

       reply	other threads:[~2023-12-11 23:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20231211094840.642118-1-lizhi.xu@windriver.com>
2023-12-11 23:16 ` kernel test robot [this message]
2023-12-13  3:25   ` [PATCH] radix-tree: fix memory leak in radix_tree_insert Lizhi Xu

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=202312120651.92GGXeX4-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizhi.xu@windriver.com \
    --cc=mani@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=pabeni@redhat.com \
    --cc=syzbot+006987d1be3586e13555@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).