From patchwork Wed Feb 13 05:16:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 10809127 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8213714E1 for ; Wed, 13 Feb 2019 05:16:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 685512C01A for ; Wed, 13 Feb 2019 05:16:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B7662C037; Wed, 13 Feb 2019 05:16:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA97C2C01A for ; Wed, 13 Feb 2019 05:16:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726328AbfBMFQY (ORCPT ); Wed, 13 Feb 2019 00:16:24 -0500 Received: from orcrist.hmeau.com ([104.223.48.154]:57668 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726155AbfBMFQY (ORCPT ); Wed, 13 Feb 2019 00:16:24 -0500 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtps (Exim 4.89 #2 (Debian)) id 1gtmuB-0005Dv-CN; Wed, 13 Feb 2019 13:16:19 +0800 Received: from herbert by gondobar with local (Exim 4.89) (envelope-from ) id 1gtmu6-0001Vl-O7; Wed, 13 Feb 2019 13:16:14 +0800 Subject: [PATCH 2/2] mac80211: Free mpath object when rhashtable insertion fails References: <20190213050551.x3jffq3ipghw6g2m@gondor.apana.org.au> To: David Miller , johannes@sipsolutions.net, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, j@w1.fi, tgraf@suug.ch, johannes.berg@intel.com Message-Id: From: Herbert Xu Date: Wed, 13 Feb 2019 13:16:14 +0800 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When rhashtable insertion fails the mesh table code doesn't free the now-orphan mesh path object. This patch fixes that. Signed-off-by: Herbert Xu --- net/mac80211/mesh_pathtbl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 984ed433a8bc..93fdd9a7d72c 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c @@ -432,17 +432,18 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata, hlist_add_head(&new_mpath->walk_list, &tbl->walk_head); } while (unlikely(ret == -EEXIST && !mpath)); - if (ret && ret != -EEXIST) + if (ret) + kfree(new_mpath); + + if (ret != -EEXIST) return ERR_PTR(ret); /* At this point either new_mpath was added, or we found a * matching entry already in the table; in the latter case * free the unnecessary new entry. */ - if (ret == -EEXIST) { - kfree(new_mpath); + if (ret == -EEXIST) new_mpath = mpath; - } sdata->u.mesh.mesh_paths_generation++; return new_mpath; } @@ -473,6 +474,8 @@ int mpp_path_add(struct ieee80211_sub_if_data *sdata, mesh_rht_params); if (!ret) hlist_add_head(&new_mpath->walk_list, &tbl->walk_head); + else + kfree(new_mpath); sdata->u.mesh.mpp_paths_generation++; return ret;