All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@01.org, Herbert Xu <herbert@gondor.apana.org.au>
Cc: kbuild-all@01.org, David Miller <davem@davemloft.net>,
	johannes@sipsolutions.net, linux-wireless@vger.kernel.org,
	netdev@vger.kernel.org, j@w1.fi, tgraf@suug.ch,
	johannes.berg@intel.com
Subject: Re: [PATCH 2/2] mac80211: Free mpath object when rhashtable insertion fails
Date: Thu, 14 Feb 2019 08:52:00 +0300	[thread overview]
Message-ID: <20190214055159.GA2304@kadam> (raw)
In-Reply-To: <E1gtmu6-0001Vl-O7@gondobar>

Hi Herbert,

url:    https://github.com/0day-ci/linux/commits/Herbert-Xu/mac80211-Fix-incorrect-usage-of-rhashtable-walk-API/20190213-181325
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211-next.git master

smatch warnings:
net/mac80211/mesh_pathtbl.c:439 mesh_path_add() warn: passing zero to 'ERR_PTR'

# https://github.com/0day-ci/linux/commit/a0886e834aacf883ceaf0c34c842c4cdb4d318fd
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout a0886e834aacf883ceaf0c34c842c4cdb4d318fd
vim +/ERR_PTR +439 net/mac80211/mesh_pathtbl.c

b15dc38b9 Bob Copeland         2016-02-28  390  
eb2b9311f Luis Carlos Cobo     2008-02-23  391  /**
eb2b9311f Luis Carlos Cobo     2008-02-23  392   * mesh_path_add - allocate and add a new path to the mesh path table
bf7cd94dc Johannes Berg        2013-02-15  393   * @dst: destination address of the path (ETH_ALEN length)
f698d856f Jasper Bryant-Greene 2008-08-03  394   * @sdata: local subif
eb2b9311f Luis Carlos Cobo     2008-02-23  395   *
af901ca18 André Goddard Rosa   2009-11-14  396   * Returns: 0 on success
eb2b9311f Luis Carlos Cobo     2008-02-23  397   *
eb2b9311f Luis Carlos Cobo     2008-02-23  398   * State: the initial state of the new path is set to 0
eb2b9311f Luis Carlos Cobo     2008-02-23  399   */
ae76eef02 Bob Copeland         2013-03-29  400  struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata,
ae76eef02 Bob Copeland         2013-03-29  401  				const u8 *dst)
eb2b9311f Luis Carlos Cobo     2008-02-23  402  {
349eb8cf4 Johannes Berg        2011-05-14  403  	struct mesh_table *tbl;
eb2b9311f Luis Carlos Cobo     2008-02-23  404  	struct mesh_path *mpath, *new_mpath;
60854fd94 Bob Copeland         2016-03-02  405  	int ret;
eb2b9311f Luis Carlos Cobo     2008-02-23  406  
b203ca391 Joe Perches          2012-05-08  407  	if (ether_addr_equal(dst, sdata->vif.addr))
eb2b9311f Luis Carlos Cobo     2008-02-23  408  		/* never add ourselves as neighbours */
ae76eef02 Bob Copeland         2013-03-29  409  		return ERR_PTR(-ENOTSUPP);
eb2b9311f Luis Carlos Cobo     2008-02-23  410  
eb2b9311f Luis Carlos Cobo     2008-02-23  411  	if (is_multicast_ether_addr(dst))
ae76eef02 Bob Copeland         2013-03-29  412  		return ERR_PTR(-ENOTSUPP);
eb2b9311f Luis Carlos Cobo     2008-02-23  413  
472dbc45d Johannes Berg        2008-09-11  414  	if (atomic_add_unless(&sdata->u.mesh.mpaths, 1, MESH_MAX_MPATHS) == 0)
ae76eef02 Bob Copeland         2013-03-29  415  		return ERR_PTR(-ENOSPC);
ae76eef02 Bob Copeland         2013-03-29  416  
b15dc38b9 Bob Copeland         2016-02-28  417  	new_mpath = mesh_path_new(sdata, dst, GFP_ATOMIC);
402d7752e Pavel Emelyanov      2008-05-06  418  	if (!new_mpath)
60854fd94 Bob Copeland         2016-03-02  419  		return ERR_PTR(-ENOMEM);
402d7752e Pavel Emelyanov      2008-05-06  420  
60854fd94 Bob Copeland         2016-03-02  421  	tbl = sdata->u.mesh.mesh_paths;
60854fd94 Bob Copeland         2016-03-02  422  	do {
60854fd94 Bob Copeland         2016-03-02  423  		ret = rhashtable_lookup_insert_fast(&tbl->rhead,
60854fd94 Bob Copeland         2016-03-02  424  						    &new_mpath->rhash,
60854fd94 Bob Copeland         2016-03-02  425  						    mesh_rht_params);
f84e71a94 Pavel Emelyanov      2008-05-06  426  
60854fd94 Bob Copeland         2016-03-02  427  		if (ret == -EEXIST)
60854fd94 Bob Copeland         2016-03-02  428  			mpath = rhashtable_lookup_fast(&tbl->rhead,
60854fd94 Bob Copeland         2016-03-02  429  						       dst,
60854fd94 Bob Copeland         2016-03-02  430  						       mesh_rht_params);
05b0152f1 Herbert Xu           2019-02-13  431  		else if (!ret)
05b0152f1 Herbert Xu           2019-02-13  432  			hlist_add_head(&new_mpath->walk_list, &tbl->walk_head);
60854fd94 Bob Copeland         2016-03-02  433  	} while (unlikely(ret == -EEXIST && !mpath));
f5ea9120b Johannes Berg        2009-08-07  434  
a0886e834 Herbert Xu           2019-02-13  435  	if (ret)
a0886e834 Herbert Xu           2019-02-13  436  		kfree(new_mpath);
a0886e834 Herbert Xu           2019-02-13  437  
a0886e834 Herbert Xu           2019-02-13  438  	if (ret != -EEXIST)
60854fd94 Bob Copeland         2016-03-02 @439  		return ERR_PTR(ret);

                                                         if (ret && ret != -EEXIST) ?

ae76eef02 Bob Copeland         2013-03-29  440  
60854fd94 Bob Copeland         2016-03-02  441  	/* At this point either new_mpath was added, or we found a
60854fd94 Bob Copeland         2016-03-02  442  	 * matching entry already in the table; in the latter case
60854fd94 Bob Copeland         2016-03-02  443  	 * free the unnecessary new entry.
60854fd94 Bob Copeland         2016-03-02  444  	 */
a0886e834 Herbert Xu           2019-02-13  445  	if (ret == -EEXIST)
60854fd94 Bob Copeland         2016-03-02  446  		new_mpath = mpath;
60854fd94 Bob Copeland         2016-03-02  447  	sdata->u.mesh.mesh_paths_generation++;
60854fd94 Bob Copeland         2016-03-02  448  	return new_mpath;
18889231e Javier Cardona       2009-08-10  449  }
eb2b9311f Luis Carlos Cobo     2008-02-23  450  

:::::: The code at line 439 was first introduced by commit
:::::: 60854fd94573f0d3b80b55b40cf0140a0430f3ab mac80211: mesh: convert path table to rhashtable

:::::: TO: Bob Copeland <me@bobcopeland.com>
:::::: CC: Johannes Berg <johannes.berg@intel.com>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

  reply	other threads:[~2019-02-14  5:53 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13  5:05 [PATCH 0/2] mac80211: Fix incorrect usage of rhashtable walk API Herbert Xu
2019-02-13  5:16 ` [PATCH 1/2] mac80211: Use linked list instead of rhashtable walk for mesh tables Herbert Xu
2019-02-13 13:47   ` Herbert Xu
2019-02-13  5:16 ` [PATCH 2/2] mac80211: Free mpath object when rhashtable insertion fails Herbert Xu
2019-02-14  5:52   ` Dan Carpenter [this message]
2019-02-13  5:25 ` [PATCH] mac80211: Use rhashtable_lookup_get_insert_fast instead of racy code Herbert Xu
2019-02-13  5:34 ` [PATCH] rhashtable: Remove obsolete rhashtable_walk_init function Herbert Xu
     [not found]   ` <201902131934.29Pw8ywP%fengguang.wu@intel.com>
2019-02-13 13:41     ` Herbert Xu
2019-02-13 14:38 ` [v2 PATCH 0/4] mac80211: Fix incorrect usage of rhashtable walk API Herbert Xu
2019-02-13 14:39   ` [PATCH 1/4] mac80211: Use linked list instead of rhashtable walk for mesh tables Herbert Xu
2019-02-13 14:39   ` [PATCH 2/4] mac80211: Free mpath object when rhashtable insertion fails Herbert Xu
2019-02-13 15:04     ` Johannes Berg
2019-02-14  9:41       ` Herbert Xu
2019-02-14 14:04       ` Herbert Xu
2019-02-13 14:39   ` [PATCH 3/4] mac80211: Use rhashtable_lookup_get_insert_fast instead of racy code Herbert Xu
2019-02-13 14:39   ` [PATCH 4/4] rhashtable: Remove obsolete rhashtable_walk_init function Herbert Xu
2019-02-13 14:55   ` [v2 PATCH 0/4] mac80211: Fix incorrect usage of rhashtable walk API Johannes Berg
2019-02-14 14:02   ` [v3 " Herbert Xu
2019-02-14 14:03     ` [PATCH 1/4] mac80211: Use linked list instead of rhashtable walk for mesh tables Herbert Xu
2019-02-14 14:03     ` [PATCH 2/4] mac80211: Free mpath object when rhashtable insertion fails Herbert Xu
2019-02-14 14:03     ` [PATCH 3/4] mac80211: Use rhashtable_lookup_get_insert_fast instead of racy code Herbert Xu
2019-02-14 14:03     ` [PATCH 4/4] rhashtable: Remove obsolete rhashtable_walk_init function Herbert Xu
2019-02-15 12:21     ` [v3 PATCH 0/4] mac80211: Fix incorrect usage of rhashtable walk API Johannes Berg
2019-02-18 10:25       ` Herbert 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=20190214055159.GA2304@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=j@w1.fi \
    --cc=johannes.berg@intel.com \
    --cc=johannes@sipsolutions.net \
    --cc=kbuild-all@01.org \
    --cc=kbuild@01.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /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.