Skip to content

Commit 72ec0bc

Browse files
SinkFinderdavem330
authored andcommitted
team: fix memory leaks
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 <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent fccb442 commit 72ec0bc

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/net/team/team.c

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

23622362
hdr = genlmsg_put(skb, portid, seq, &team_nl_family, flags | NLM_F_MULTI,
23632363
TEAM_CMD_OPTIONS_GET);
2364-
if (!hdr)
2364+
if (!hdr) {
2365+
nlmsg_free(skb);
23652366
return -EMSGSIZE;
2367+
}
23662368

23672369
if (nla_put_u32(skb, TEAM_ATTR_TEAM_IFINDEX, team->dev->ifindex))
23682370
goto nla_put_failure;
@@ -2634,8 +2636,10 @@ static int team_nl_send_port_list_get(struct team *team, u32 portid, u32 seq,
26342636

26352637
hdr = genlmsg_put(skb, portid, seq, &team_nl_family, flags | NLM_F_MULTI,
26362638
TEAM_CMD_PORT_LIST_GET);
2637-
if (!hdr)
2639+
if (!hdr) {
2640+
nlmsg_free(skb);
26382641
return -EMSGSIZE;
2642+
}
26392643

26402644
if (nla_put_u32(skb, TEAM_ATTR_TEAM_IFINDEX, team->dev->ifindex))
26412645
goto nla_put_failure;

0 commit comments

Comments
 (0)