Merge branch 'urgent.2021.05.20a' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-microblaze.git] / drivers / xen / xen-front-pgdir-shbuf.c
index 48a658d..81b6e13 100644 (file)
@@ -305,11 +305,18 @@ static int backend_map(struct xen_front_pgdir_shbuf *buf)
 
        /* Save handles even if error, so we can unmap. */
        for (cur_page = 0; cur_page < buf->num_pages; cur_page++) {
-               buf->backend_map_handles[cur_page] = map_ops[cur_page].handle;
-               if (unlikely(map_ops[cur_page].status != GNTST_okay))
+               if (likely(map_ops[cur_page].status == GNTST_okay)) {
+                       buf->backend_map_handles[cur_page] =
+                               map_ops[cur_page].handle;
+               } else {
+                       buf->backend_map_handles[cur_page] =
+                               INVALID_GRANT_HANDLE;
+                       if (!ret)
+                               ret = -ENXIO;
                        dev_err(&buf->xb_dev->dev,
                                "Failed to map page %d: %d\n",
                                cur_page, map_ops[cur_page].status);
+               }
        }
 
        if (ret) {