RDMA/ucma: Check that user doesn't overflow QP state
[pandora-kernel.git] / drivers / infiniband / core / ucma.c
index 79d0333..4396ab6 100644 (file)
@@ -873,6 +873,9 @@ static ssize_t ucma_init_qp_attr(struct ucma_file *file,
        if (copy_from_user(&cmd, inbuf, sizeof(cmd)))
                return -EFAULT;
 
+       if (cmd.qp_state > IB_QPS_ERR)
+               return -EINVAL;
+
        ctx = ucma_get_ctx(file, cmd.id);
        if (IS_ERR(ctx))
                return PTR_ERR(ctx);