Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1531859 > unrolled thread

[PATCH v2] vxlan: fix a potential issue when create a new vxlan fdb entry.

Started byHaishuang Yan <yanhaishuang@cmss.chinamobile.com>
First post2016-11-29 03:10 +0100
Last post2016-11-30 18:10 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v2] vxlan: fix a potential issue when create a new vxlan fdb entry. Haishuang Yan <yanhaishuang@cmss.chinamobile.com> - 2016-11-29 03:10 +0100
    Re: [PATCH v2] vxlan: fix a potential issue when create a new vxlan  fdb entry. Jiri Benc <jbenc@redhat.com> - 2016-11-29 09:30 +0100
    Re: [PATCH v2] vxlan: fix a potential issue when create a new  vxlan fdb entry. David Miller <davem@davemloft.net> - 2016-11-30 18:10 +0100

#1531859 — [PATCH v2] vxlan: fix a potential issue when create a new vxlan fdb entry.

FromHaishuang Yan <yanhaishuang@cmss.chinamobile.com>
Date2016-11-29 03:10 +0100
Subject[PATCH v2] vxlan: fix a potential issue when create a new vxlan fdb entry.
Message-ID<sIG1P-1Tu-1@gated-at.bofh.it>
vxlan_fdb_append may return error, so add the proper check,
otherwise it will cause memory leak.

Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>

Changes in v2:
  - Unnecessary to initialize rc to zero.
---
 drivers/net/vxlan.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 21e92be..bb70dd5 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -611,6 +611,7 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
 	struct vxlan_rdst *rd = NULL;
 	struct vxlan_fdb *f;
 	int notify = 0;
+	int rc;
 
 	f = __vxlan_find_mac(vxlan, mac);
 	if (f) {
@@ -641,8 +642,7 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
 		if ((flags & NLM_F_APPEND) &&
 		    (is_multicast_ether_addr(f->eth_addr) ||
 		     is_zero_ether_addr(f->eth_addr))) {
-			int rc = vxlan_fdb_append(f, ip, port, vni, ifindex,
-						  &rd);
+			rc = vxlan_fdb_append(f, ip, port, vni, ifindex, &rd);
 
 			if (rc < 0)
 				return rc;
@@ -673,7 +673,11 @@ static int vxlan_fdb_create(struct vxlan_dev *vxlan,
 		INIT_LIST_HEAD(&f->remotes);
 		memcpy(f->eth_addr, mac, ETH_ALEN);
 
-		vxlan_fdb_append(f, ip, port, vni, ifindex, &rd);
+		rc = vxlan_fdb_append(f, ip, port, vni, ifindex, &rd);
+		if (rc < 0) {
+			kfree(f);
+			return rc;
+		}
 
 		++vxlan->addrcnt;
 		hlist_add_head_rcu(&f->hlist,
-- 
1.8.3.1

[toc] | [next] | [standalone]


#1531989 — Re: [PATCH v2] vxlan: fix a potential issue when create a new vxlan fdb entry.

FromJiri Benc <jbenc@redhat.com>
Date2016-11-29 09:30 +0100
SubjectRe: [PATCH v2] vxlan: fix a potential issue when create a new vxlan fdb entry.
Message-ID<sILXz-5RH-3@gated-at.bofh.it>
In reply to#1531859
On Tue, 29 Nov 2016 09:59:36 +0800, Haishuang Yan wrote:
> vxlan_fdb_append may return error, so add the proper check,
> otherwise it will cause memory leak.
> 
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
> 
> Changes in v2:
>   - Unnecessary to initialize rc to zero.

Acked-by: Jiri Benc <jbenc@redhat.com>

[toc] | [prev] | [next] | [standalone]


#1533444 — Re: [PATCH v2] vxlan: fix a potential issue when create a new vxlan fdb entry.

FromDavid Miller <davem@davemloft.net>
Date2016-11-30 18:10 +0100
SubjectRe: [PATCH v2] vxlan: fix a potential issue when create a new vxlan fdb entry.
Message-ID<sJgyl-s0-3@gated-at.bofh.it>
In reply to#1531859
From: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
Date: Tue, 29 Nov 2016 09:59:36 +0800

> vxlan_fdb_append may return error, so add the proper check,
> otherwise it will cause memory leak.
> 
> Signed-off-by: Haishuang Yan <yanhaishuang@cmss.chinamobile.com>
> 
> Changes in v2:
>   - Unnecessary to initialize rc to zero.

Applied, thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web