From patchwork Wed Feb 27 14:34:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 10831735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D26541399 for ; Wed, 27 Feb 2019 14:35:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B716B2DD1D for ; Wed, 27 Feb 2019 14:35:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA1522E16D; Wed, 27 Feb 2019 14:35:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1A8242DD1D for ; Wed, 27 Feb 2019 14:35:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B062A8E0003; Wed, 27 Feb 2019 09:34:59 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A8B048E0001; Wed, 27 Feb 2019 09:34:59 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 906368E0003; Wed, 27 Feb 2019 09:34:59 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by kanga.kvack.org (Postfix) with ESMTP id 37B7F8E0001 for ; Wed, 27 Feb 2019 09:34:59 -0500 (EST) Received: by mail-ed1-f71.google.com with SMTP id i20so7017445edv.21 for ; Wed, 27 Feb 2019 06:34:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:thread-topic :thread-index:date:message-id:accept-language:content-language :content-transfer-encoding:mime-version; bh=ydPKA5bYPG4oJWewMmo9KXUQqkLI9/V32BgyLDEghQg=; b=lBGqnz4eS+72ClaNg8/SbEo3f1E3RqIBtwqstUjkUgX9TN+MGp7RSLgDVpPO14fml0 Hy4gERtx5x9CpL2kkJfg+3jAuSn1OcgsFnwkZbP+qguoZ964is4NQzFAC+IeALVUZ5Yw AoINB88UiTlGEWyIowPRQWEdjMhJ2EyXHes2HiHhaccleawGgxWJcQ/xnE3Ocxqhhjip an6BbEf9Q8W4oGwq11XEneQTkrUsgjuVqNNzG4vxcWm/gr0jHCc5vfeOj6i/5wnHjvTk CdmPvrcfDARR6X3gZ86PH/RQOSImxAP92BjZfIVK5SA+ASBwcu/tXBW19SGI5z+pcjdZ 2Qjg== X-Gm-Message-State: AHQUAuYECljNRX+hIA7zEBG+UkMxpqpH1mjBDMwERqnTbciZ3QXOpqhy 67708YhNOGLJ/PPSelLBgf2rhsnB29PrcZ+TnoHXa155qrOjFPRv5sZByJ5IUNbgAIzbF6ehCEg 4mII3g2mrZU1BnCo9sjqbaHrvTtqH4wVLtWZCkc2kj84TDnKNCvmf0o4wa7EQe1i99g== X-Received: by 2002:a50:9012:: with SMTP id b18mr2676431eda.30.1551278098469; Wed, 27 Feb 2019 06:34:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IbSH7qzukT6KMLIomIw+ziwtawXvqQtSmd6qxbWWILu9z0xCMJ7qhP4kXnhuRNu6JOR6NNf X-Received: by 2002:a50:9012:: with SMTP id b18mr2676369eda.30.1551278097418; Wed, 27 Feb 2019 06:34:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551278097; cv=none; d=google.com; s=arc-20160816; b=gF6VDIa4Q6oBuLAaoSgbhx+oJOZ7JmkGPxdQpTOgFb0miFJxkKJezPktMy6rW/oNsN KohP9klgaWwIyAvGKGWBEHVLKnH27INdbhYOMCzmPiL1xZK5IQwKlIDnaJc6xkHpQfgV na66OA9tNDxJt8LFPdR3Ed6DVAfqGvjULk6hjYbrCxdPel9B1uJMD/ppz+1BK7AZz29G UXaK5We6WJOfFjhqNztAU4OWQi0rebR8RPxSypj09i4+6vIB2NfrlQoCHlqvDxl/Sm/v yfsFMwiUTIpITrbjn8kI7EOYdP0ibuobQ1ef1smnshMl4s8qmrRBbPQFRNf+0je+x3eV cICQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:content-transfer-encoding:content-language :accept-language:message-id:date:thread-index:thread-topic:subject :cc:to:from:dkim-signature; bh=ydPKA5bYPG4oJWewMmo9KXUQqkLI9/V32BgyLDEghQg=; b=x+l+Z7fGXHp+2oYuBVV/YfXXS9JUqDnXbRSwdnZjY15xpgYF6U7wf434mbcoFF7crw EW3tJPlxeiGr3E9/7LreG4LQwgawP4c8hzWO/5HT8xwTxBiYJ4GupAWVgUzi2ULT6aqi 1Tkja2Hn9+VyQlVCw9Ni2keU1Au5aahZlTetEr4W4nwyUqxg4iwd70OFj4Buy1yLY3RF 91v9vBu6buLKs10m0Ke1WRS4ewillK8F3KmSzvH6D032WQ3UnY5RLgFv/uH99Zkxo8S6 0qfIYX8zbwA8SB0njDRaZUrRJALiSuNSy/4COhgnkYMPj4yfLXU5o6SjXdWr0EfxjG6a /YLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=XQ2F1o0t; spf=pass (google.com: domain of peng.fan@nxp.com designates 40.107.14.75 as permitted sender) smtp.mailfrom=peng.fan@nxp.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140075.outbound.protection.outlook.com. [40.107.14.75]) by mx.google.com with ESMTPS id y15si3742410edd.290.2019.02.27.06.34.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 27 Feb 2019 06:34:57 -0800 (PST) Received-SPF: pass (google.com: domain of peng.fan@nxp.com designates 40.107.14.75 as permitted sender) client-ip=40.107.14.75; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=XQ2F1o0t; spf=pass (google.com: domain of peng.fan@nxp.com designates 40.107.14.75 as permitted sender) smtp.mailfrom=peng.fan@nxp.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ydPKA5bYPG4oJWewMmo9KXUQqkLI9/V32BgyLDEghQg=; b=XQ2F1o0t/ldbkVL6p9C67OWuVdSsZ58a5cwp25mBexMrRriEr7BLSCIaY4d6IdImFrgTHqjxirh015qfpnnVjQ2hk+I2PMze3QupSNzEKTGMqWouBcohbJXj6uCOe/D3IsanNnOHpi9lezydZPHIipgOyz07/BQbRft0K/U0tNQ= Received: from AM0PR04MB4481.eurprd04.prod.outlook.com (52.135.147.15) by AM0PR04MB4387.eurprd04.prod.outlook.com (52.135.148.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.15; Wed, 27 Feb 2019 14:34:55 +0000 Received: from AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::a51f:134d:b530:f185]) by AM0PR04MB4481.eurprd04.prod.outlook.com ([fe80::a51f:134d:b530:f185%5]) with mapi id 15.20.1643.019; Wed, 27 Feb 2019 14:34:55 +0000 From: Peng Fan To: "akpm@linux-foundation.org" , "labbott@redhat.com" , "iamjoonsoo.kim@lge.com" , "mhocko@suse.com" , "vbabka@suse.cz" , "rppt@linux.vnet.ibm.com" , "m.szyprowski@samsung.com" , "andreyknvl@google.com" , "catalin.marinas@arm.com" CC: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "van.freenix@gmail.com" , Peng Fan Subject: [PATCH V2] mm/cma: cma_declare_contiguous: correct err handling Thread-Topic: [PATCH V2] mm/cma: cma_declare_contiguous: correct err handling Thread-Index: AQHUzqmb2gOP19YBOEqDLHalEnAZ9g== Date: Wed, 27 Feb 2019 14:34:55 +0000 Message-ID: <20190227144631.16708-1-peng.fan@nxp.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.16.4 x-clientproxiedby: HK0P153CA0037.APCP153.PROD.OUTLOOK.COM (2603:1096:203:17::25) To AM0PR04MB4481.eurprd04.prod.outlook.com (2603:10a6:208:70::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=peng.fan@nxp.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [119.31.174.71] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 8bc17a3f-4e3b-4dc1-e998-08d69cc0bdc4 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(4618075)(2017052603328)(7153060)(7193020);SRVR:AM0PR04MB4387; x-ms-traffictypediagnostic: AM0PR04MB4387: x-ms-exchange-purlcount: 1 x-microsoft-exchange-diagnostics: =?iso-8859-1?q?1=3BAM0PR04MB4387=3B23=3Ay6?= =?iso-8859-1?q?ljAC1GU2xbUvOeSDE1klbwV7PpK2frWB0TKaR7HaciBCqWYx4u27n9lSHkF0?= =?iso-8859-1?q?uOAtM8gOJLu0qCwXX7mNPWYa88W4yE/4WDqZNEJV8QC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?HXDtU4vU4/ysvTEaBKwHIe6omkVRXHTZ6QcSTRFG7sppWJlbzMh75ctMHNn6?= =?iso-8859-1?q?CY89Rv+ry1V/43UgvvbFWiAzHK0dw5SmXF4+XwyIDB+7qBuFc7iY14L9d3jW?= =?iso-8859-1?q?tnDY51id8BaQRNKVu7ofpPw3O86nMRJs27uCwFmRco/5rh3Z/MIBt53hBlpM?= =?iso-8859-1?q?z9SPAb4aZ5hIAWRVi/ARDo0gpR42hpbi4mVNiqm4EWyMRatB6Hmcc0znkP9g?= =?iso-8859-1?q?sDMuQZmaJXtHj6MC6n+6tfM4vg0dROxE5+9hkiZwy8GUS3zwnpuTEaLszDlU?= =?iso-8859-1?q?8DtUA+BRJ8AgchXWbMzdGMAFdzmkZ7y3RkvYIm8g=3D=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 0961DF5286 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(346002)(366004)(39860400002)(376002)(136003)(396003)(199004)(189003)(256004)(97736004)(8936002)(7416002)(99286004)(52116002)(966005)(71190400001)(71200400001)(68736007)(486006)(26005)(14444005)(14454004)(478600001)(186003)(2616005)(476003)(2501003)(81166006)(8676002)(81156014)(7736002)(44832011)(36756003)(305945005)(106356001)(105586002)(5660300002)(1076003)(66066001)(53936002)(6306002)(2906002)(102836004)(6512007)(386003)(6506007)(6486002)(110136005)(316002)(54906003)(2201001)(6436002)(86362001)(4326008)(3846002)(25786009)(6116002)(50226002);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR04MB4387;H:AM0PR04MB4481.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 64NH0bMY1y0xSNMIiVr9w1CMjnecvCr+0IJWiZ82vQVUP7MBreS9MHZUK7wgXAJ/uFw8izpPixWqQlzYuiu+AKO11BYkrfEh+uQTrJgCFjnFYvEAjz86RKUxGEePDhqeFF5ARtmXVThVTicew1xHI7Rx4Anke9ItyT6aEiIjndA21q9FWmQVeZgwSZsvMvtQWaGSfyuYW74zp24Vr4pkvfC/UThdCUiqvFobMD/zt+yC7kD8WgfNjqtr+3+8AKMMy5iolZh9cGso3JhN8NK0BuWGl3sOGvrfRf1ls/F7BFeE6e1Z+1CrbTO4rGysqAOR8crB1hbrYxEVVG8SDzPXasBBpruURs9sscizT5VUhK9d8UKQItCmY6tWPb7EZLtDQqSTUjNoEjRPhYpXbPUnqd5HHoBqUcjTLXdltw2gv8U= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8bc17a3f-4e3b-4dc1-e998-08d69cc0bdc4 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Feb 2019 14:34:50.8506 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB4387 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP 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: Signed-off-by: Peng Fan Reviewed-by: Catalin Marinas Reviewed-by: Mike Rapoport --- V2: Per Mike's comments, add more information in commit log Add R-B 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;