Skip to content

Commit 4212115

Browse files
SinkFindergregkh
authored andcommitted
team: fix memory leaks
[ Upstream commit 72ec0bc64b9a5d8e0efcb717abfc757746b101b7 ] In functions team_nl_send_port_list_get() and team_nl_send_options_get(), pointer skb keeps the return value of nlmsg_new(). When the call to genlmsg_put() fails, the memory is not freed(). This will result in memory leak bugs. Fixes: 9b00cf2 ("team: implement multipart netlink messages for options transfers") Signed-off-by: Pan Bian <bianpan2016@163.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fa63895 commit 4212115

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

drivers/net/team/team.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2343,8 +2343,10 @@ static int team_nl_send_options_get(struct team *team, u32 portid, u32 seq,
23432343

23442344
hdr = genlmsg_put(skb, portid, seq, &team_nl_family, flags | NLM_F_MULTI,
23452345
TEAM_CMD_OPTIONS_GET);
2346-
if (!hdr)
2346+
if (!hdr) {
2347+
nlmsg_free(skb);
23472348
return -EMSGSIZE;
2349+
}
23482350

23492351
if (nla_put_u32(skb, TEAM_ATTR_TEAM_IFINDEX, team->dev->ifindex))
23502352
goto nla_put_failure;
@@ -2611,8 +2613,10 @@ static int team_nl_send_port_list_get(struct team *team, u32 portid, u32 seq,
26112613

26122614
hdr = genlmsg_put(skb, portid, seq, &team_nl_family, flags | NLM_F_MULTI,
26132615
TEAM_CMD_PORT_LIST_GET);
2614-
if (!hdr)
2616+
if (!hdr) {
2617+
nlmsg_free(skb);
26152618
return -EMSGSIZE;
2619+
}
26162620

26172621
if (nla_put_u32(skb, TEAM_ATTR_TEAM_IFINDEX, team->dev->ifindex))
26182622
goto nla_put_failure;

0 commit comments

Comments
 (0)