{
        unsigned char *mappage;
 
-       if (page >= bitmap->pages) {
-               /* This can happen if bitmap_start_sync goes beyond
-                * End-of-device while looking for a whole page.
-                * It is harmless.
-                */
-               return -EINVAL;
-       }
-
+       WARN_ON_ONCE(page >= bitmap->pages);
        if (bitmap->bp[page].hijacked) /* it's hijacked, don't try to alloc */
                return 0;
 
        sector_t csize;
        int err;
 
+       if (page >= bitmap->pages) {
+               /*
+                * This can happen if bitmap_start_sync goes beyond
+                * End-of-device while looking for a whole page or
+                * user set a huge number to sysfs bitmap_set_bits.
+                */
+               return NULL;
+       }
        err = md_bitmap_checkpage(bitmap, page, create, 0);
 
        if (bitmap->bp[page].hijacked ||