All of lore.kernel.org
 help / color / mirror / Atom feed
From: MichelleJin <shjy180909@gmail.com>
To: davem@davemloft.net, kuba@kernel.org, yoshfuji@linux-ipv6.org,
	dsahern@kernel.org, johannes@sipsolutions.net
Cc: saeedm@nvidia.com, leon@kernel.org, roid@nvidia.com,
	paulb@nvidia.com, ozsh@nvidia.com, lariel@nvidia.com,
	cmi@nvidia.com, netdev@vger.kernel.org,
	linux-rdma@vger.kernel.org, linux-wireless@vger.kernel.org
Subject: [PATCH net-next v4 3/3] net: mac80211: check return value of rhashtable_init
Date: Mon, 27 Sep 2021 03:34:57 +0000	[thread overview]
Message-ID: <20210927033457.1020967-4-shjy180909@gmail.com> (raw)
In-Reply-To: <20210927033457.1020967-1-shjy180909@gmail.com>

When rhashtable_init() fails, it returns -EINVAL.
However, since error return value of rhashtable_init is not checked,
it can cause use of uninitialized pointers.
So, fix unhandled errors of rhashtable_init.

Signed-off-by: MichelleJin <shjy180909@gmail.com>
---

v1->v2:
 - change commit message
 - fix possible memory leaks
v2->v3:
 - nothing changed
v3-> v4:
 - nothing changed

 net/mac80211/mesh_pathtbl.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index efbefcbac3ac..7cab1cf09bf1 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -60,7 +60,10 @@ static struct mesh_table *mesh_table_alloc(void)
 	atomic_set(&newtbl->entries,  0);
 	spin_lock_init(&newtbl->gates_lock);
 	spin_lock_init(&newtbl->walk_lock);
-	rhashtable_init(&newtbl->rhead, &mesh_rht_params);
+	if (rhashtable_init(&newtbl->rhead, &mesh_rht_params)) {
+		kfree(newtbl);
+		return NULL;
+	}
 
 	return newtbl;
 }
-- 
2.25.1


  parent reply	other threads:[~2021-09-27  3:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27  3:34 [PATCH net-next v4 0/3] check return value of rhashtable_init in mlx5e, ipv6, mac80211 MichelleJin
2021-09-27  3:34 ` [PATCH net-next v4 1/3] net/mlx5e: check return value of rhashtable_init MichelleJin
2021-09-29 11:00   ` Roi Dayan
2021-09-27  3:34 ` [PATCH net-next v4 2/3] net: ipv6: " MichelleJin
2021-09-27 13:43   ` David Ahern
2021-09-27  3:34 ` MichelleJin [this message]
2021-09-28 12:10 ` [PATCH net-next v4 0/3] check return value of rhashtable_init in mlx5e, ipv6, mac80211 patchwork-bot+netdevbpf

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=20210927033457.1020967-4-shjy180909@gmail.com \
    --to=shjy180909@gmail.com \
    --cc=cmi@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=lariel@nvidia.com \
    --cc=leon@kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ozsh@nvidia.com \
    --cc=paulb@nvidia.com \
    --cc=roid@nvidia.com \
    --cc=saeedm@nvidia.com \
    --cc=yoshfuji@linux-ipv6.org \
    /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.