tipc: fix memory leak in tipc_nl_compat_publ_dump
Subsystems (3)
PATCH 1/1 tipc: fix memory leak in tipc_nl_compat_publ_dump
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 <[email protected]>
--- net/tipc/netlink_compat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/tipc/netlink_compat.c +3 -1
@@ -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) {
Signature · 1 line
2.20.1
Quoted 7 lines · Gustavo A. R. Silva
There is a memory leak in case
genlmsg_putfails.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 <[email protected]>
Acked-by Ying Xue <[email protected]>
Quoted 21 lines
--- net/tipc/netlink_compat.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)net/tipc/netlink_compat.c +3
-1@@ -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) {
From: "Gustavo A. R. Silva" <[email protected]>
Date: Sat, 5 Jan 2019 10:52:23 -0600
Quoted 7 lines
There is a memory leak in case
genlmsg_putfails.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 <[email protected]>
Applied, thank you.