Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1026741yba; Thu, 4 Apr 2019 02:44:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqzR0FhIwm19ei21BxiLZe19msji9affgaF5C/m3SMJ6h07FScp1so8UH+ZlGC3Mg8eFHyZp X-Received: by 2002:a63:c84c:: with SMTP id l12mr4822825pgi.287.1554371065282; Thu, 04 Apr 2019 02:44:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554371065; cv=none; d=google.com; s=arc-20160816; b=Msdh2j/Qzp8rvma/Weba1fqex6zBI9NzhhxZyKpw3IDnIJJF+tpkz3hcyl3SGutTH4 zY4OnqsX0DEpHbBPfMhB5conN9rgJnUsKhW3R3eamtqaGvEjNiMTWTJFJBRUFbMTQOBU P57mHRbzogrks/oKOS7AR+0mLwqcOM+yR+ixUubiO2qHaXkgSk1SpAjgNoaf/iUH16CB a90WUAdxmAqgpFCOroTDCRaZlc0WYA6czqpTBmb5cVEVoaj7xpQ7PCTMSNsteqRrX2T3 BdxW6UojnO8X8PNH1qzSHsKsBRTxrcn7ZmPF23AD6Wt6zjmBvtccczV22qEtKrbJq55g j9fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Hf51U532jcCcwZVkvu2obo1JKhI9GAdAGY2oQnhT2AU=; b=rGrIg5tH32gWEYieKyUVGvA/7NUapdDi0tXwiz1r0olgv36d16pYVAw0tpP1X9PJ8X 1sjfJc8ACMU2Drb9FbnPYKZb5NYcyxaaoVVQP7SZ5K1pza7dbkz3AcrgyneFDQcBdrcW MM38RmNcK6fmMIOg2V+yw8+3my3bzWW83x6isJYQh2F+WMbwMwW3MkJZeKbl1dZ30sWV EYAhh9aTAJVbHPewS9mT3fQea7MdAV5QhD8ZoZY3qFSAvB4SmdCWoNoAwJyZAL636FL1 /8NGu3RvA6ZRT9bpU8+ma+Luwf447h0eubAHGe8btvtJXG8qm6DRJjw7ydh0F4c677Qg ekpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MeLAMtpv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w12si2883708plz.67.2019.04.04.02.44.09; Thu, 04 Apr 2019 02:44:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MeLAMtpv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731052AbfDDJne (ORCPT + 99 others); Thu, 4 Apr 2019 05:43:34 -0400 Received: from mail.kernel.org ([198.145.29.99]:37426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731272AbfDDJAi (ORCPT ); Thu, 4 Apr 2019 05:00:38 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D4C182177E; Thu, 4 Apr 2019 09:00:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368437; bh=aogPuVBhN4S8+y8O86/5VhUHbLI+iCJ9SKUA5l4QSvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MeLAMtpvq/K+Rkg/v0Ve53CsQhlzf8JXiz2TC2dD1gOvvOdCT0Cne47c+DKhMSY1I bIm4YCAhvGWK99ydjO0aAc0EBfgOIIkhUiLbj4FUAkizF4/IZ7iDyh5eLxsLjd+plY yzWFMllCOtXREBZCYAk93x3m+GlsrpPMeJ+W3D08= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peng Fan , Catalin Marinas , Mike Rapoport , Laura Abbott , Joonsoo Kim , Michal Hocko , Vlastimil Babka , Marek Szyprowski , Andrey Konovalov , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 4.19 024/187] mm/cma.c: cma_declare_contiguous: correct err handling Date: Thu, 4 Apr 2019 10:46:01 +0200 Message-Id: <20190404084604.238946549@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 0d3bd18a5efd66097ef58622b898d3139790aa9d ] In case cma_init_reserved_mem failed, need to free the memblock allocated by memblock_reserve or memblock_alloc_range. Quote Catalin's comments: https://lkml.org/lkml/2019/2/26/482 Kmemleak is supposed to work with the memblock_{alloc,free} pair and it ignores the memblock_reserve() as a memblock_alloc() implementation detail. It is, however, tolerant to memblock_free() being called on a sub-range or just a different range from a previous memblock_alloc(). So the original patch looks fine to me. FWIW: Link: http://lkml.kernel.org/r/20190227144631.16708-1-peng.fan@nxp.com Signed-off-by: Peng Fan Reviewed-by: Catalin Marinas Reviewed-by: Mike Rapoport Cc: Laura Abbott Cc: Joonsoo Kim Cc: Michal Hocko Cc: Vlastimil Babka Cc: Marek Szyprowski Cc: Andrey Konovalov Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/cma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/cma.c b/mm/cma.c index 4cb76121a3ab..bfe9f5397165 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.19.1