linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/cma: cma_declare_contiguous: correct err handling
@ 2019-02-14 12:45 Peng Fan
  2019-02-14 20:38 ` Andrew Morton
  0 siblings, 1 reply; 8+ messages in thread
From: Peng Fan @ 2019-02-14 12:45 UTC (permalink / raw)
  To: akpm, labbott, mhocko, vbabka, iamjoonsoo.kim, rppt,
	m.szyprowski, rdunlap, andreyknvl
  Cc: linux-mm, linux-kernel, van.freenix, Peng Fan

In case cma_init_reserved_mem failed, need to free the memblock allocated
by memblock_reserve or memblock_alloc_range.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---

V1:
 code inspection, I do not met failure in cma_init_reserved_mem.

 mm/cma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/mm/cma.c b/mm/cma.c
index c7b39dd3b4f6..f4f3a8a57d86 100644
--- a/mm/cma.c
+++ b/mm/cma.c
@@ -353,12 +353,14 @@ int __init cma_declare_contiguous(phys_addr_t base,
 
 	ret = cma_init_reserved_mem(base, size, order_per_bit, name, res_cma);
 	if (ret)
-		goto err;
+		goto free_mem;
 
 	pr_info("Reserved %ld MiB at %pa\n", (unsigned long)size / SZ_1M,
 		&base);
 	return 0;
 
+free_mem:
+	memblock_free(base, size);
 err:
 	pr_err("Failed to reserve %ld MiB\n", (unsigned long)size / SZ_1M);
 	return ret;
-- 
2.16.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-02-26 14:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-14 12:45 [PATCH] mm/cma: cma_declare_contiguous: correct err handling Peng Fan
2019-02-14 20:38 ` Andrew Morton
2019-02-15  1:30   ` Peng Fan
2019-02-19 16:55   ` Vlastimil Babka
2019-02-19 17:46     ` Mike Rapoport
2019-02-22 12:55       ` Peng Fan
2019-02-26 11:11         ` Mike Rapoport
2019-02-26 14:52       ` Catalin Marinas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).