From e40c2313486fce1972049ba37966624e50140225 Mon Sep 17 00:00:00 2001 From: Mat Martineau Date: Thu, 9 Jan 2020 07:59:14 -0800 Subject: [PATCH] BACKPORT: net: Make sock protocol value checks more specific SK_PROTOCOL_MAX is only used in two places, for DECNet and AX.25. The limits have more to do with the those protocol definitions than they do with the data type of sk_protocol, so remove SK_PROTOCOL_MAX and use U8_MAX directly. Reviewed-by: Eric Dumazet Change-Id: I3d1e12f0cd3ddb2db11a2eaad5e3a1a85c59db06 Signed-off-by: Mat Martineau Signed-off-by: David S. Miller --- include/net/sock.h | 1 - net/ax25/af_ax25.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/net/sock.h b/include/net/sock.h index ee1e551a8d16..216dcbcdc060 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -463,7 +463,6 @@ struct sock { sk_userlocks : 4, sk_protocol : 8, sk_type : 16; -#define SK_PROTOCOL_MAX U8_MAX u16 sk_gso_max_segs; u8 sk_pacing_shift; unsigned long sk_lingertime; diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 7861f2747f84..2a10b97320d8 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c @@ -834,7 +834,7 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol, struct sock *sk; ax25_cb *ax25; - if (protocol < 0 || protocol > SK_PROTOCOL_MAX) + if (protocol < 0 || protocol > U8_MAX) return -EINVAL; if (!net_eq(net, &init_net))