* [PATCH net-2.6] macvlan: do a proper cleanup in macvlan_common_newlink()
@ 2010-05-24 15:58 Jiri Pirko
2010-05-24 17:02 ` Jiri Pirko
0 siblings, 1 reply; 4+ messages in thread
From: Jiri Pirko @ 2010-05-24 15:58 UTC (permalink / raw)
To: netdev; +Cc: davem, kaber
Fixes possible memory leak.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
drivers/net/macvlan.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 4e238af..5f4694b 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -634,11 +634,17 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
err = register_netdevice(dev);
if (err < 0)
- return err;
+ goto destroy_port;
list_add_tail(&vlan->list, &port->vlans);
netif_stacked_transfer_operstate(lowerdev, dev);
+
return 0;
+
+destroy_port:
+ macvlan_port_destroy(lowerdev);
+
+ return err;
}
EXPORT_SYMBOL_GPL(macvlan_common_newlink);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-2.6] macvlan: do a proper cleanup in macvlan_common_newlink()
2010-05-24 15:58 [PATCH net-2.6] macvlan: do a proper cleanup in macvlan_common_newlink() Jiri Pirko
@ 2010-05-24 17:02 ` Jiri Pirko
2010-05-24 18:56 ` Patrick McHardy
0 siblings, 1 reply; 4+ messages in thread
From: Jiri Pirko @ 2010-05-24 17:02 UTC (permalink / raw)
To: netdev; +Cc: davem, kaber
Mon, May 24, 2010 at 05:58:58PM CEST, jpirko@redhat.com wrote:
>Fixes possible memory leak.
>
>Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>---
> drivers/net/macvlan.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
>diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
>index 4e238af..5f4694b 100644
>--- a/drivers/net/macvlan.c
>+++ b/drivers/net/macvlan.c
>@@ -634,11 +634,17 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
>
> err = register_netdevice(dev);
> if (err < 0)
>- return err;
>+ goto destroy_port;
>
> list_add_tail(&vlan->list, &port->vlans);
> netif_stacked_transfer_operstate(lowerdev, dev);
>+
> return 0;
>+
>+destroy_port:
>+ macvlan_port_destroy(lowerdev);
>+
>+ return err;
> }
> EXPORT_SYMBOL_GPL(macvlan_common_newlink);
>
>--
>1.6.6.1
Actually it should be rather like this:
Subject: [PATCH net-2.6] macvlan: do proper cleanup in macvlan_common_newlink() V2
Fixes possible memory leak.
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
---
drivers/net/macvlan.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 4e238af..87e8d4c 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -634,11 +634,18 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
err = register_netdevice(dev);
if (err < 0)
- return err;
+ goto destroy_port;
list_add_tail(&vlan->list, &port->vlans);
netif_stacked_transfer_operstate(lowerdev, dev);
+
return 0;
+
+destroy_port:
+ if (list_empty(&port->vlans))
+ macvlan_port_destroy(lowerdev);
+
+ return err;
}
EXPORT_SYMBOL_GPL(macvlan_common_newlink);
--
1.6.6.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-2.6] macvlan: do a proper cleanup in macvlan_common_newlink()
2010-05-24 17:02 ` Jiri Pirko
@ 2010-05-24 18:56 ` Patrick McHardy
2010-05-25 1:41 ` David Miller
0 siblings, 1 reply; 4+ messages in thread
From: Patrick McHardy @ 2010-05-24 18:56 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev, davem
Jiri Pirko wrote:
> Mon, May 24, 2010 at 05:58:58PM CEST, jpirko@
> Subject: [PATCH net-2.6] macvlan: do proper cleanup in macvlan_common_newlink() V2
>
> Fixes possible memory leak.
Looks good, thanks.
> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Acked-by: Patrick McHardy <kaber@trash.net>
> ---
> drivers/net/macvlan.c | 9 ++++++++-
> 1 files changed, 8 insertions(+), 1 deletions(-)
>
> diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
> index 4e238af..87e8d4c 100644
> --- a/drivers/net/macvlan.c
> +++ b/drivers/net/macvlan.c
> @@ -634,11 +634,18 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
>
> err = register_netdevice(dev);
> if (err < 0)
> - return err;
> + goto destroy_port;
>
> list_add_tail(&vlan->list, &port->vlans);
> netif_stacked_transfer_operstate(lowerdev, dev);
> +
> return 0;
> +
> +destroy_port:
> + if (list_empty(&port->vlans))
> + macvlan_port_destroy(lowerdev);
> +
> + return err;
> }
> EXPORT_SYMBOL_GPL(macvlan_common_newlink);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-2.6] macvlan: do a proper cleanup in macvlan_common_newlink()
2010-05-24 18:56 ` Patrick McHardy
@ 2010-05-25 1:41 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2010-05-25 1:41 UTC (permalink / raw)
To: kaber; +Cc: jpirko, netdev
From: Patrick McHardy <kaber@trash.net>
Date: Mon, 24 May 2010 20:56:32 +0200
> Jiri Pirko wrote:
>> Mon, May 24, 2010 at 05:58:58PM CEST, jpirko@
>> Subject: [PATCH net-2.6] macvlan: do proper cleanup in macvlan_common_newlink() V2
>>
>> Fixes possible memory leak.
>
> Looks good, thanks.
>
>> Signed-off-by: Jiri Pirko <jpirko@redhat.com>
>
> Acked-by: Patrick McHardy <kaber@trash.net>
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-25 1:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-24 15:58 [PATCH net-2.6] macvlan: do a proper cleanup in macvlan_common_newlink() Jiri Pirko
2010-05-24 17:02 ` Jiri Pirko
2010-05-24 18:56 ` Patrick McHardy
2010-05-25 1:41 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).