All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] macvlan: Fix memleak in macvlan_changelink_sources
@ 2020-06-18 13:26 Zheng Bin
  2020-06-20  3:15 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Zheng Bin @ 2020-06-18 13:26 UTC (permalink / raw)
  To: davem, kuba, michael-dev, netdev, linux-kernel; +Cc: zhengbin13, yi.zhang

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@huawei.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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH -next] macvlan: Fix memleak in macvlan_changelink_sources
  2020-06-18 13:26 [PATCH -next] macvlan: Fix memleak in macvlan_changelink_sources Zheng Bin
@ 2020-06-20  3:15 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-06-20  3:15 UTC (permalink / raw)
  To: zhengbin13; +Cc: kuba, michael-dev, netdev, linux-kernel, yi.zhang

From: Zheng Bin <zhengbin13@huawei.com>
Date: Thu, 18 Jun 2020 21:26:29 +0800

> 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@huawei.com>

Bug fixes should never be submitted against net-next.

They should instead be submitted against 'net'.

Thank you.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-20  3:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-18 13:26 [PATCH -next] macvlan: Fix memleak in macvlan_changelink_sources Zheng Bin
2020-06-20  3:15 ` David Miller

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.