]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
net/rds: Fix incorrect error handling
authorHåkon Bugge <Haakon.Bugge@oracle.com>
Fri, 8 Dec 2017 15:55:22 +0000 (16:55 +0100)
committerHåkon Bugge <Haakon.Bugge@oracle.com>
Wed, 31 Jan 2018 15:05:17 +0000 (16:05 +0100)
Commit 5f58d7e81c2f ("net/rds: reduce memory footprint during
ib_post_recv in IB transport") removes order two allocations used to
receive fragments. Instead, zero order allocations are used. However,
said commit has incorrect error handling.

This commit fixes this.

Orabug: 27469760

Signed-off-by: Håkon Bugge <haakon.bugge@oracle.com>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
(cherry picked from commit a3740c633f4f7089d5cbb11b4a9d19c79c96f746)

net/rds/ib_recv.c

index e6b853de541d74210c77a741d12ad3f86fc627cc..69c516508bcaefb38a9b7a45797a5f07b57b710c 100644 (file)
@@ -389,7 +389,9 @@ static struct rds_page_frag *rds_ib_refill_one_frag(struct rds_ib_connection *ic
                                                       PAGE_SIZE, page_mask);
                        if (ret) {
                                for_each_sg(frag->f_sg, s, ic->i_frag_pages, j)
-                                       __free_pages(sg_page(s), get_order(s->length));
+                                       /* Its the ith fragment we couldn't allocate */
+                                       if (j < i)
+                                               __free_pages(sg_page(s), get_order(s->length));
                                kmem_cache_free(rds_ib_frag_slab, frag);
                                atomic_sub(ic->i_frag_pages, &rds_ib_allocation);
                                return NULL;
@@ -574,7 +576,9 @@ static int rds_ib_srq_prefill_one(struct rds_ib_device *rds_ibdev,
                                               PAGE_SIZE, page_mask);
                if (ret) {
                        for_each_sg(recv->r_frag->f_sg, s, num_sge, j)
-                               __free_pages(sg_page(s), get_order(s->length));
+                               /* Its the ith fragment we couldn't allocate */
+                               if (j < i)
+                                       __free_pages(sg_page(s), get_order(s->length));
                        kmem_cache_free(rds_ib_frag_slab, recv->r_frag);
                        goto out;
                }