Merge tag 'xfs-5.17-merge-3' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux
[linux-2.6-microblaze.git] / crypto / af_alg.c
index 3dd5a77..e1ea185 100644 (file)
@@ -931,16 +931,19 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
                        sg_unmark_end(sg + sgl->cur - 1);
 
                do {
+                       struct page *pg;
                        unsigned int i = sgl->cur;
 
                        plen = min_t(size_t, len, PAGE_SIZE);
 
-                       sg_assign_page(sg + i, alloc_page(GFP_KERNEL));
-                       if (!sg_page(sg + i)) {
+                       pg = alloc_page(GFP_KERNEL);
+                       if (!pg) {
                                err = -ENOMEM;
                                goto unlock;
                        }
 
+                       sg_assign_page(sg + i, pg);
+
                        err = memcpy_from_msg(page_address(sg_page(sg + i)),
                                              msg, plen);
                        if (err) {