These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / net / irda / af_irda.c
index ee0ea25..923abd6 100644 (file)
@@ -1086,6 +1086,9 @@ static int irda_create(struct net *net, struct socket *sock, int protocol,
        struct sock *sk;
        struct irda_sock *self;
 
+       if (protocol < 0 || protocol > SK_PROTOCOL_MAX)
+               return -EINVAL;
+
        if (net != &init_net)
                return -EAFNOSUPPORT;
 
@@ -1100,7 +1103,7 @@ static int irda_create(struct net *net, struct socket *sock, int protocol,
        }
 
        /* Allocate networking socket */
-       sk = sk_alloc(net, PF_IRDA, GFP_KERNEL, &irda_proto);
+       sk = sk_alloc(net, PF_IRDA, GFP_KERNEL, &irda_proto, kern);
        if (sk == NULL)
                return -ENOMEM;
 
@@ -2123,8 +2126,7 @@ static int irda_setsockopt(struct socket *sock, int level, int optname,
                }
 
                /* Unregister any old registration */
-               if (self->skey)
-                       irlmp_unregister_service(self->skey);
+               irlmp_unregister_service(self->skey);
 
                self->skey = irlmp_register_service((__u16) opt);
                break;