From 169292b03d665c252b6ab2450dfcf832e5b2c687 Mon Sep 17 00:00:00 2001 From: =?utf8?q?H=C3=A5kon=20Bugge?= Date: Fri, 8 Dec 2017 16:55:22 +0100 Subject: [PATCH] net/rds: Fix incorrect error handling MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Yuval Shaia Acked-by: Santosh Shilimkar (cherry picked from commit a3740c633f4f7089d5cbb11b4a9d19c79c96f746) --- net/rds/ib_recv.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c index e6b853de541d..69c516508bca 100644 --- a/net/rds/ib_recv.c +++ b/net/rds/ib_recv.c @@ -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; } -- 2.50.1