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

mpls: fix uninitialized in_label var warning in mpls_getroute

Fix the below warning generated by static checker:
net/mpls/af_mpls.c:2111 mpls_getroute()
error: uninitialized symbol 'in_label'."

Fixes: 397fc9e5cefe ("mpls: route get support")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Roopa Prabhu and committed by
David S. Miller
a906c1aa 11bafd54

+8 -4
+8 -4
net/mpls/af_mpls.c
··· 2076 2076 { 2077 2077 struct net *net = sock_net(in_skb->sk); 2078 2078 u32 portid = NETLINK_CB(in_skb).portid; 2079 + u32 in_label = LABEL_NOT_SPECIFIED; 2079 2080 struct nlattr *tb[RTA_MAX + 1]; 2080 2081 u32 labels[MAX_NEW_LABELS]; 2081 2082 struct mpls_shim_hdr *hdr; ··· 2087 2086 struct nlmsghdr *nlh; 2088 2087 struct sk_buff *skb; 2089 2088 struct mpls_nh *nh; 2090 - int err = -EINVAL; 2091 - u32 in_label; 2092 2089 u8 n_labels; 2090 + int err; 2093 2091 2094 2092 err = nlmsg_parse(in_nlh, sizeof(*rtm), tb, RTA_MAX, 2095 2093 rtm_mpls_policy, extack); ··· 2101 2101 u8 label_count; 2102 2102 2103 2103 if (nla_get_labels(tb[RTA_DST], 1, &label_count, 2104 - &in_label, extack)) 2104 + &in_label, extack)) { 2105 + err = -EINVAL; 2105 2106 goto errout; 2107 + } 2106 2108 2107 - if (in_label < MPLS_LABEL_FIRST_UNRESERVED) 2109 + if (!mpls_label_ok(net, in_label, extack)) { 2110 + err = -EINVAL; 2108 2111 goto errout; 2112 + } 2109 2113 } 2110 2114 2111 2115 rt = mpls_route_input_rcu(net, in_label);