Skip to content

Commit 9419e2e

Browse files
Zhang Qilongksacilotto
authored andcommitted
ipv6: Fix error path to cancel the meseage
BugLink: https://bugs.launchpad.net/bugs/1908561 [ Upstream commit ceb736e ] 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 <hulkci@huawei.com> Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com> Link: https://lore.kernel.org/r/20201112080950.1476302-1-zhangqilong3@huawei.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Ian May <ian.may@canonical.com>
1 parent 9e502ec commit 9419e2e

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
@@ -4984,8 +4984,10 @@ static int inet6_fill_ifmcaddr(struct sk_buff *skb, struct ifmcaddr6 *ifmca,
49844984
return -EMSGSIZE;
49854985

49864986
if (args->netnsid >= 0 &&
4987-
nla_put_s32(skb, IFA_TARGET_NETNSID, args->netnsid))
4987+
nla_put_s32(skb, IFA_TARGET_NETNSID, args->netnsid)) {
4988+
nlmsg_cancel(skb, nlh);
49884989
return -EMSGSIZE;
4990+
}
49894991

49904992
put_ifaddrmsg(nlh, 128, IFA_F_PERMANENT, scope, ifindex);
49914993
if (nla_put_in6_addr(skb, IFA_MULTICAST, &ifmca->mca_addr) < 0 ||
@@ -5016,8 +5018,10 @@ static int inet6_fill_ifacaddr(struct sk_buff *skb, struct ifacaddr6 *ifaca,
50165018
return -EMSGSIZE;
50175019

50185020
if (args->netnsid >= 0 &&
5019-
nla_put_s32(skb, IFA_TARGET_NETNSID, args->netnsid))
5021+
nla_put_s32(skb, IFA_TARGET_NETNSID, args->netnsid)) {
5022+
nlmsg_cancel(skb, nlh);
50205023
return -EMSGSIZE;
5024+
}
50215025

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

0 commit comments

Comments
 (0)