[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1431612382.27831.52.camel@edumazet-glaptop2.roam.corp.google.com>
Date: Thu, 14 May 2015 07:06:22 -0700
From: Eric Dumazet <eric.dumazet@...il.com>
To: Ying Xue <ying.xue@...driver.com>
Cc: jiri@...nulli.us, sfeldma@...il.com, netdev@...r.kernel.org
Subject: Re: [PATCH net-next] rocker: fix a neigh entry leak issue
On Thu, 2015-05-14 at 15:06 +0800, Ying Xue wrote:
> Once we get a neighbour through looking up arp cache or creating a
> new one in rocker_port_ipv4_resolve(), the neighbour's refcount is
> already taken. But we don't put the refcount again after it's used,
> which make the neighbour entry leaked.
>
> Signed-off-by: Ying Xue <ying.xue@...driver.com>
> ---
> drivers/net/ethernet/rocker/rocker.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
> index 1fc006b..7504540 100644
> --- a/drivers/net/ethernet/rocker/rocker.c
> +++ b/drivers/net/ethernet/rocker/rocker.c
> @@ -3053,6 +3053,7 @@ static int rocker_port_ipv4_resolve(struct rocker_port *rocker_port,
> else
> neigh_event_send(n, NULL);
>
> + neigh_release(n);
> return err;
> }
>
I do not think this fix is complete.
neigh_create() can return an error, and we'll crash.
diff --git a/drivers/net/ethernet/rocker/rocker.c b/drivers/net/ethernet/rocker/rocker.c
index f0a9cb44be6bedc2171f6c9f79200cfa5d0bb0fa..ff0befbd8b4351c6f8fef93513967d5450d29e64 100644
--- a/drivers/net/ethernet/rocker/rocker.c
+++ b/drivers/net/ethernet/rocker/rocker.c
@@ -3037,11 +3037,11 @@ static int rocker_port_ipv4_resolve(struct rocker_port *rocker_port,
struct neighbour *n = __ipv4_neigh_lookup(dev, (__force u32)ip_addr);
int err = 0;
- if (!n)
+ if (!n) {
n = neigh_create(&arp_tbl, &ip_addr, dev);
- if (!n)
- return -ENOMEM;
-
+ if (IS_ERR(n))
+ return PTR_ERR(n);
+ }
/* If the neigh is already resolved, then go ahead and
* install the entry, otherwise start the ARP process to
* resolve the neigh.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists