linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tipc: fix memory leak in tipc_nl_compat_publ_dump
@ 2019-01-05 16:52 Gustavo A. R. Silva
  2019-01-06  5:41 ` Ying Xue
  2019-01-07 16:45 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2019-01-05 16:52 UTC (permalink / raw)
  To: Kangjie Lu, Jon Maloy, Ying Xue, David S. Miller
  Cc: netdev, tipc-discussion, linux-kernel, Gustavo A. R. Silva

There is a memory leak in case genlmsg_put fails.

Fix this by freeing *args* before return.

Addresses-Coverity-ID: 1476406 ("Resource leak")
Fixes: 46273cf7e009 ("tipc: fix a missing check of genlmsg_put")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 net/tipc/netlink_compat.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index 40f5cae623a7..77e4b2418f30 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -904,8 +904,10 @@ static int tipc_nl_compat_publ_dump(struct tipc_nl_compat_msg *msg, u32 sock)
 
 	hdr = genlmsg_put(args, 0, 0, &tipc_genl_family, NLM_F_MULTI,
 			  TIPC_NL_PUBL_GET);
-	if (!hdr)
+	if (!hdr) {
+		kfree_skb(args);
 		return -EMSGSIZE;
+	}
 
 	nest = nla_nest_start(args, TIPC_NLA_SOCK);
 	if (!nest) {
-- 
2.20.1


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

* Re: [PATCH] tipc: fix memory leak in tipc_nl_compat_publ_dump
  2019-01-05 16:52 [PATCH] tipc: fix memory leak in tipc_nl_compat_publ_dump Gustavo A. R. Silva
@ 2019-01-06  5:41 ` Ying Xue
  2019-01-07 16:45 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Ying Xue @ 2019-01-06  5:41 UTC (permalink / raw)
  To: Gustavo A. R. Silva, Kangjie Lu, Jon Maloy, David S. Miller
  Cc: netdev, tipc-discussion, linux-kernel

On 1/6/19 12:52 AM, Gustavo A. R. Silva wrote:
> There is a memory leak in case genlmsg_put fails.
> 
> Fix this by freeing *args* before return.
> 
> Addresses-Coverity-ID: 1476406 ("Resource leak")
> Fixes: 46273cf7e009 ("tipc: fix a missing check of genlmsg_put")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Acked-by: Ying Xue <ying.xue@windriver.com>

> ---
>  net/tipc/netlink_compat.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
> index 40f5cae623a7..77e4b2418f30 100644
> --- a/net/tipc/netlink_compat.c
> +++ b/net/tipc/netlink_compat.c
> @@ -904,8 +904,10 @@ static int tipc_nl_compat_publ_dump(struct tipc_nl_compat_msg *msg, u32 sock)
>  
>  	hdr = genlmsg_put(args, 0, 0, &tipc_genl_family, NLM_F_MULTI,
>  			  TIPC_NL_PUBL_GET);
> -	if (!hdr)
> +	if (!hdr) {
> +		kfree_skb(args);
>  		return -EMSGSIZE;
> +	}
>  
>  	nest = nla_nest_start(args, TIPC_NLA_SOCK);
>  	if (!nest) {
> 

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

* Re: [PATCH] tipc: fix memory leak in tipc_nl_compat_publ_dump
  2019-01-05 16:52 [PATCH] tipc: fix memory leak in tipc_nl_compat_publ_dump Gustavo A. R. Silva
  2019-01-06  5:41 ` Ying Xue
@ 2019-01-07 16:45 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-01-07 16:45 UTC (permalink / raw)
  To: gustavo; +Cc: kjlu, jon.maloy, ying.xue, netdev, tipc-discussion, linux-kernel

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Sat, 5 Jan 2019 10:52:23 -0600

> There is a memory leak in case genlmsg_put fails.
> 
> Fix this by freeing *args* before return.
> 
> Addresses-Coverity-ID: 1476406 ("Resource leak")
> Fixes: 46273cf7e009 ("tipc: fix a missing check of genlmsg_put")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied, thank you.

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

end of thread, other threads:[~2019-01-07 16:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-05 16:52 [PATCH] tipc: fix memory leak in tipc_nl_compat_publ_dump Gustavo A. R. Silva
2019-01-06  5:41 ` Ying Xue
2019-01-07 16:45 ` 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).