Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ipv6: Do cleanup if attribute validation fails in multipath route

As Nicolas noted, if gateway validation fails walking the multipath
attribute the code should jump to the cleanup to free previously
allocated memory.

Fixes: 1ff15a710a86 ("ipv6: Check attribute length for RTA_GATEWAY when deleting multipath route")
Signed-off-by: David Ahern <dsahern@kernel.org>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Link: https://lore.kernel.org/r/20220103170555.94638-1-dsahern@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

David Ahern and committed by
Jakub Kicinski
95bdba23 e30a845b

+3 -5
+3 -5
net/ipv6/route.c
··· 5277 5277 5278 5278 nla = nla_find(attrs, attrlen, RTA_GATEWAY); 5279 5279 if (nla) { 5280 - int ret; 5281 - 5282 - ret = fib6_gw_from_attr(&r_cfg.fc_gateway, nla, 5280 + err = fib6_gw_from_attr(&r_cfg.fc_gateway, nla, 5283 5281 extack); 5284 - if (ret) 5285 - return ret; 5282 + if (err) 5283 + goto cleanup; 5286 5284 5287 5285 r_cfg.fc_flags |= RTF_GATEWAY; 5288 5286 }