Merge branch 'mm-pkeys-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / drivers / misc / mic / scif / scif_rma.c
index 0fa0d242b29589474f0abb081f8c439a117615ec..e0203b1a20fd17fe88d9db3dc882d4d64eed2cc5 100644 (file)
@@ -1509,7 +1509,7 @@ off_t scif_register_pinned_pages(scif_epd_t epd,
        if ((map_flags & SCIF_MAP_FIXED) &&
            ((ALIGN(offset, PAGE_SIZE) != offset) ||
            (offset < 0) ||
-           (offset + (off_t)len < offset)))
+           (len > LONG_MAX - offset)))
                return -EINVAL;
 
        might_sleep();
@@ -1612,7 +1612,7 @@ off_t scif_register(scif_epd_t epd, void *addr, size_t len, off_t offset,
        if ((map_flags & SCIF_MAP_FIXED) &&
            ((ALIGN(offset, PAGE_SIZE) != offset) ||
            (offset < 0) ||
-           (offset + (off_t)len < offset)))
+           (len > LONG_MAX - offset)))
                return -EINVAL;
 
        /* Unsupported protection requested */
@@ -1730,7 +1730,8 @@ scif_unregister(scif_epd_t epd, off_t offset, size_t len)
 
        /* Offset is not page aligned or offset+len wraps around */
        if ((ALIGN(offset, PAGE_SIZE) != offset) ||
-           (offset + (off_t)len < offset))
+           (offset < 0) ||
+           (len > LONG_MAX - offset))
                return -EINVAL;
 
        err = scif_verify_epd(ep);