* [PATCH] vxlan: fix a potential issue when create a new vxlan fdb entry.
@ 2016-11-28 7:02 Haishuang Yan
2016-11-28 11:37 ` Jiri Benc
0 siblings, 1 reply; 2+ messages in thread
From: Haishuang Yan @ 2016-11-28 7:02 UTC (permalink / raw)
To: David S. Miller, Jiri Benc, Hannes Frederic Sowa, Pravin B Shelar
Cc: netdev, linux-kernel, Haishuang Yan
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>
---
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..3b7b237 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 = 0;
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] vxlan: fix a potential issue when create a new vxlan fdb entry.
2016-11-28 7:02 [PATCH] vxlan: fix a potential issue when create a new vxlan fdb entry Haishuang Yan
@ 2016-11-28 11:37 ` Jiri Benc
0 siblings, 0 replies; 2+ messages in thread
From: Jiri Benc @ 2016-11-28 11:37 UTC (permalink / raw)
To: Haishuang Yan
Cc: David S. Miller, Hannes Frederic Sowa, Pravin B Shelar, netdev,
linux-kernel
On Mon, 28 Nov 2016 15:02:23 +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>
> ---
> 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..3b7b237 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 = 0;
The initialization to 0 should not be needed. Looks good otherwise.
Thanks,
Jiri
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-28 11:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-28 7:02 [PATCH] vxlan: fix a potential issue when create a new vxlan fdb entry Haishuang Yan
2016-11-28 11:37 ` Jiri Benc
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.