Skip to content

Commit 69a1ecf

Browse files
leitaokuba-moo
authored andcommitted
mpls: Use nlmsg_payload in mpls_valid_getroute_req
Leverage the new nlmsg_payload() helper to avoid checking for message size and then reading the nlmsg data. Signed-off-by: Breno Leitao <[email protected]> Reviewed-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 8cf1e30 commit 69a1ecf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/mpls/af_mpls.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,8 @@ static int mpls_valid_getroute_req(struct sk_buff *skb,
22882288
struct rtmsg *rtm;
22892289
int i, err;
22902290

2291-
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*rtm))) {
2291+
rtm = nlmsg_payload(nlh, sizeof(*rtm));
2292+
if (!rtm) {
22922293
NL_SET_ERR_MSG_MOD(extack,
22932294
"Invalid header for get route request");
22942295
return -EINVAL;
@@ -2298,7 +2299,6 @@ static int mpls_valid_getroute_req(struct sk_buff *skb,
22982299
return nlmsg_parse_deprecated(nlh, sizeof(*rtm), tb, RTA_MAX,
22992300
rtm_mpls_policy, extack);
23002301

2301-
rtm = nlmsg_data(nlh);
23022302
if ((rtm->rtm_dst_len && rtm->rtm_dst_len != 20) ||
23032303
rtm->rtm_src_len || rtm->rtm_tos || rtm->rtm_table ||
23042304
rtm->rtm_protocol || rtm->rtm_scope || rtm->rtm_type) {

0 commit comments

Comments
 (0)