Skip to content

Commit ceb736e

Browse files
Zhang Qilongkuba-moo
authored andcommitted
ipv6: Fix error path to cancel the meseage
genlmsg_cancel() needs to be called in the error path of inet6_fill_ifmcaddr and inet6_fill_ifacaddr to cancel the message. Fixes: 6ecf4c3 ("ipv6: enable IFA_TARGET_NETNSID for RTM_GETADDR") Reported-by: Hulk Robot <[email protected]> Signed-off-by: Zhang Qilong <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9c2e14b commit ceb736e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

net/ipv6/addrconf.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5022,8 +5022,10 @@ static int inet6_fill_ifmcaddr(struct sk_buff *skb, struct ifmcaddr6 *ifmca,
50225022
return -EMSGSIZE;
50235023

50245024
if (args->netnsid >= 0 &&
5025-
nla_put_s32(skb, IFA_TARGET_NETNSID, args->netnsid))
5025+
nla_put_s32(skb, IFA_TARGET_NETNSID, args->netnsid)) {
5026+
nlmsg_cancel(skb, nlh);
50265027
return -EMSGSIZE;
5028+
}
50275029

50285030
put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
50295031
if (nla_put_in6_addr(skb, IFA_MULTICAST, &ifmca->mca_addr) < 0 ||
@@ -5054,8 +5056,10 @@ static int inet6_fill_ifacaddr(struct sk_buff *skb, struct ifacaddr6 *ifaca,
50545056
return -EMSGSIZE;
50555057

50565058
if (args->netnsid >= 0 &&
5057-
nla_put_s32(skb, IFA_TARGET_NETNSID, args->netnsid))
5059+
nla_put_s32(skb, IFA_TARGET_NETNSID, args->netnsid)) {
5060+
nlmsg_cancel(skb, nlh);
50585061
return -EMSGSIZE;
5062+
}
50595063

50605064
put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
50615065
if (nla_put_in6_addr(skb, IFA_ANYCAST, &ifaca->aca_addr) < 0 ||

0 commit comments

Comments
 (0)