* [PATCH net] mpls: fix uninitialized in_label var warning in mpls_getroute
@ 2017-07-07 18:21 Roopa Prabhu
2017-07-08 10:27 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Roopa Prabhu @ 2017-07-07 18:21 UTC (permalink / raw)
To: davem; +Cc: netdev, dan.carpenter
From: Roopa Prabhu <roopa@cumulusnetworks.com>
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>
---
net/mpls/af_mpls.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index bdcfb2d..ea4f4818 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -2076,6 +2076,7 @@ static int mpls_getroute(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
{
struct net *net = sock_net(in_skb->sk);
u32 portid = NETLINK_CB(in_skb).portid;
+ u32 in_label = LABEL_NOT_SPECIFIED;
struct nlattr *tb[RTA_MAX + 1];
u32 labels[MAX_NEW_LABELS];
struct mpls_shim_hdr *hdr;
@@ -2086,9 +2087,8 @@ static int mpls_getroute(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
struct nlmsghdr *nlh;
struct sk_buff *skb;
struct mpls_nh *nh;
- int err = -EINVAL;
- u32 in_label;
u8 n_labels;
+ int err;
err = nlmsg_parse(in_nlh, sizeof(*rtm), tb, RTA_MAX,
rtm_mpls_policy, extack);
@@ -2101,11 +2101,15 @@ static int mpls_getroute(struct sk_buff *in_skb, struct nlmsghdr *in_nlh,
u8 label_count;
if (nla_get_labels(tb[RTA_DST], 1, &label_count,
- &in_label, extack))
+ &in_label, extack)) {
+ err = -EINVAL;
goto errout;
+ }
- if (in_label < MPLS_LABEL_FIRST_UNRESERVED)
+ if (!mpls_label_ok(net, in_label, extack)) {
+ err = -EINVAL;
goto errout;
+ }
}
rt = mpls_route_input_rcu(net, in_label);
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] mpls: fix uninitialized in_label var warning in mpls_getroute
2017-07-07 18:21 [PATCH net] mpls: fix uninitialized in_label var warning in mpls_getroute Roopa Prabhu
@ 2017-07-08 10:27 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-07-08 10:27 UTC (permalink / raw)
To: roopa; +Cc: netdev, dan.carpenter
From: Roopa Prabhu <roopa@cumulusnetworks.com>
Date: Fri, 7 Jul 2017 11:21:49 -0700
> From: Roopa Prabhu <roopa@cumulusnetworks.com>
>
> 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>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-07-08 10:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-07 18:21 [PATCH net] mpls: fix uninitialized in_label var warning in mpls_getroute Roopa Prabhu
2017-07-08 10:27 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.