include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[firefly-linux-kernel-4.4.55.git] / net / core / scm.c
index b7ba91b074b33995deee5278fb54c30d100d041b..b88f6f9d0b97503ddd353e163e73680704cde79a 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/security.h>
 #include <linux/pid.h>
 #include <linux/nsproxy.h>
+#include <linux/slab.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -156,6 +157,8 @@ int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
                switch (cmsg->cmsg_type)
                {
                case SCM_RIGHTS:
+                       if (!sock->ops || sock->ops->family != PF_UNIX)
+                               goto error;
                        err=scm_fp_copy(cmsg, &p->fp);
                        if (err<0)
                                goto error;