Skip to content

Commit

Permalink
net: Make sock protocol value checks more specific
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Mat Martineau <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
mjmartineau authored and davem330 committed Jan 10, 2020
1 parent 6b3acfc commit e9cdced
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,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;
Expand Down
2 changes: 1 addition & 1 deletion net/ax25/af_ax25.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,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))
Expand Down
2 changes: 1 addition & 1 deletion net/decnet/af_decnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ static int dn_create(struct net *net, struct socket *sock, int protocol,
{
struct sock *sk;

if (protocol < 0 || protocol > SK_PROTOCOL_MAX)
if (protocol < 0 || protocol > U8_MAX)
return -EINVAL;

if (!net_eq(net, &init_net))
Expand Down

0 comments on commit e9cdced

Please sign in to comment.