linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rocker: fix memory leaks of fib_work on two error return paths
@ 2019-07-27 23:37 Colin King
  2019-07-28  0:32 ` David Ahern
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Colin King @ 2019-07-27 23:37 UTC (permalink / raw)
  To: David Ahern, Jiri Pirko, David S . Miller, netdev
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently there are two error return paths that leak memory allocated
to fib_work. Fix this by kfree'ing fib_work before returning.

Addresses-Coverity: ("Resource leak")
Fixes: 19a9d136f198 ("ipv4: Flag fib_info with a fib_nh using IPv6 gateway")
Fixes: dbcc4fa718ee ("rocker: Fail attempts to use routes with nexthop objects")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/net/ethernet/rocker/rocker_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/rocker/rocker_main.c b/drivers/net/ethernet/rocker/rocker_main.c
index 079f459c73a5..2c5d3f5b84dd 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -2208,10 +2208,12 @@ static int rocker_router_fib_event(struct notifier_block *nb,
 
 			if (fen_info->fi->fib_nh_is_v6) {
 				NL_SET_ERR_MSG_MOD(info->extack, "IPv6 gateway with IPv4 route is not supported");
+				kfree(fib_work);
 				return notifier_from_errno(-EINVAL);
 			}
 			if (fen_info->fi->nh) {
 				NL_SET_ERR_MSG_MOD(info->extack, "IPv4 route with nexthop objects is not supported");
+				kfree(fib_work);
 				return notifier_from_errno(-EINVAL);
 			}
 		}
-- 
2.20.1


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

* Re: [PATCH] rocker: fix memory leaks of fib_work on two error return paths
  2019-07-27 23:37 [PATCH] rocker: fix memory leaks of fib_work on two error return paths Colin King
@ 2019-07-28  0:32 ` David Ahern
  2019-07-28  7:46 ` Jiri Pirko
  2019-07-29 17:59 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Ahern @ 2019-07-28  0:32 UTC (permalink / raw)
  To: Colin King, Jiri Pirko, David S . Miller, netdev
  Cc: kernel-janitors, linux-kernel

On 7/27/19 5:37 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently there are two error return paths that leak memory allocated
> to fib_work. Fix this by kfree'ing fib_work before returning.
> 
> Addresses-Coverity: ("Resource leak")
> Fixes: 19a9d136f198 ("ipv4: Flag fib_info with a fib_nh using IPv6 gateway")
> Fixes: dbcc4fa718ee ("rocker: Fail attempts to use routes with nexthop objects")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/net/ethernet/rocker/rocker_main.c | 2 ++
>  1 file changed, 2 insertions(+)
> 

Thanks for the patch,
Reviewed-by: David Ahern <dsahern@gmail.com>

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

* Re: [PATCH] rocker: fix memory leaks of fib_work on two error return paths
  2019-07-27 23:37 [PATCH] rocker: fix memory leaks of fib_work on two error return paths Colin King
  2019-07-28  0:32 ` David Ahern
@ 2019-07-28  7:46 ` Jiri Pirko
  2019-07-29 17:59 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Jiri Pirko @ 2019-07-28  7:46 UTC (permalink / raw)
  To: Colin King
  Cc: David Ahern, David S . Miller, netdev, kernel-janitors, linux-kernel

Sun, Jul 28, 2019 at 01:37:26AM CEST, colin.king@canonical.com wrote:
>From: Colin Ian King <colin.king@canonical.com>
>
>Currently there are two error return paths that leak memory allocated
>to fib_work. Fix this by kfree'ing fib_work before returning.
>
>Addresses-Coverity: ("Resource leak")
>Fixes: 19a9d136f198 ("ipv4: Flag fib_info with a fib_nh using IPv6 gateway")
>Fixes: dbcc4fa718ee ("rocker: Fail attempts to use routes with nexthop objects")
>Signed-off-by: Colin Ian King <colin.king@canonical.com>

Acked-by: Jiri Pirko <jiri@mellanox.com>

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

* Re: [PATCH] rocker: fix memory leaks of fib_work on two error return paths
  2019-07-27 23:37 [PATCH] rocker: fix memory leaks of fib_work on two error return paths Colin King
  2019-07-28  0:32 ` David Ahern
  2019-07-28  7:46 ` Jiri Pirko
@ 2019-07-29 17:59 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-07-29 17:59 UTC (permalink / raw)
  To: colin.king; +Cc: dsahern, jiri, netdev, kernel-janitors, linux-kernel

From: Colin King <colin.king@canonical.com>
Date: Sun, 28 Jul 2019 00:37:26 +0100

> From: Colin Ian King <colin.king@canonical.com>
> 
> Currently there are two error return paths that leak memory allocated
> to fib_work. Fix this by kfree'ing fib_work before returning.
> 
> Addresses-Coverity: ("Resource leak")
> Fixes: 19a9d136f198 ("ipv4: Flag fib_info with a fib_nh using IPv6 gateway")
> Fixes: dbcc4fa718ee ("rocker: Fail attempts to use routes with nexthop objects")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied.

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

end of thread, other threads:[~2019-07-29 17:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-27 23:37 [PATCH] rocker: fix memory leaks of fib_work on two error return paths Colin King
2019-07-28  0:32 ` David Ahern
2019-07-28  7:46 ` Jiri Pirko
2019-07-29 17:59 ` 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).