[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200618132629.659977-1-zhengbin13@huawei.com>
Date: Thu, 18 Jun 2020 21:26:29 +0800
From: Zheng Bin <zhengbin13@...wei.com>
To: <davem@...emloft.net>, <kuba@...nel.org>,
<michael-dev@...i-braun.de>, <netdev@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
CC: <zhengbin13@...wei.com>, <yi.zhang@...wei.com>
Subject: [PATCH -next] macvlan: Fix memleak in macvlan_changelink_sources
macvlan_changelink_sources
if (addr)
ret = macvlan_hash_add_source(vlan, addr)
nla_for_each_attr(nla, head, len, rem)
ret = macvlan_hash_add_source(vlan, addr)
-->If fail, need to free previous malloc memory
Fixes: 79cf79abce71 ("macvlan: add source mode")
Signed-off-by: Zheng Bin <zhengbin13@...wei.com>
---
drivers/net/macvlan.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 6a6cc9f75307..0017c5d28a27 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -1379,8 +1379,10 @@ static int macvlan_changelink_sources(struct macvlan_dev *vlan, u32 mode,
addr = nla_data(nla);
ret = macvlan_hash_add_source(vlan, addr);
- if (ret)
+ if (ret) {
+ macvlan_flush_sources(vlan->port, vlan);
return ret;
+ }
}
} else {
return -EINVAL;
--
2.25.4
Powered by blists - more mailing lists