diff --git a/net/nfc/af_nfc.c b/net/nfc/af_nfc.c index d3e594eb36d0aaafebe63f439b0b5a7145657eed..256f3c57059e6c4d44d88b12008667f8680e782b 100644 --- a/net/nfc/af_nfc.c +++ b/net/nfc/af_nfc.c @@ -21,6 +21,7 @@ #include <linux/nfc.h> #include <linux/module.h> +#include <linux/nospec.h> #include "nfc.h" @@ -37,6 +38,7 @@ static int nfc_sock_create(struct net *net, struct socket *sock, int proto, if (proto < 0 || proto >= NFC_SOCKPROTO_MAX) return -EINVAL; + proto = array_index_nospec(proto, NFC_SOCKPROTO_MAX); read_lock(&proto_tab_lock); if (proto_tab[proto] && try_module_get(proto_tab[proto]->owner)) {