Skip to content

Commit e9cdced

Browse files
mjmartineaudavem330
authored andcommitted
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 <edumazet@google.com> Signed-off-by: Mat Martineau <mathew.j.martineau@linux.intel.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 6b3acfc commit e9cdced

3 files changed

Lines changed: 2 additions & 3 deletions

File tree

‎include/net/sock.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ struct sock {
458458
sk_userlocks : 4,
459459
sk_protocol : 8,
460460
sk_type : 16;
461-
#define SK_PROTOCOL_MAX U8_MAX
462461
u16 sk_gso_max_segs;
463462
u8 sk_pacing_shift;
464463
unsigned long sk_lingertime;

‎net/ax25/af_ax25.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ static int ax25_create(struct net *net, struct socket *sock, int protocol,
808808
struct sock *sk;
809809
ax25_cb *ax25;
810810

811-
if (protocol < 0 || protocol > SK_PROTOCOL_MAX)
811+
if (protocol < 0 || protocol > U8_MAX)
812812
return -EINVAL;
813813

814814
if (!net_eq(net, &init_net))

‎net/decnet/af_decnet.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ static int dn_create(struct net *net, struct socket *sock, int protocol,
670670
{
671671
struct sock *sk;
672672

673-
if (protocol < 0 || protocol > SK_PROTOCOL_MAX)
673+
if (protocol < 0 || protocol > U8_MAX)
674674
return -EINVAL;
675675

676676
if (!net_eq(net, &init_net))

0 commit comments

Comments
 (0)