From patchwork Thu Feb 14 12:45:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Fan X-Patchwork-Id: 10812623 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 68EF66C2 for ; Thu, 14 Feb 2019 12:46:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 563412DE6B for ; Thu, 14 Feb 2019 12:46:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4A7C42DEEA; Thu, 14 Feb 2019 12:46:17 +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 B632F2DED5 for ; Thu, 14 Feb 2019 12:46:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A2DC48E0002; Thu, 14 Feb 2019 07:46:15 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9DA7E8E0001; Thu, 14 Feb 2019 07:46:15 -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 8C8A08E0002; Thu, 14 Feb 2019 07:46:15 -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 3348B8E0001 for ; Thu, 14 Feb 2019 07:46:15 -0500 (EST) Received: by mail-ed1-f71.google.com with SMTP id x47so2404693eda.8 for ; Thu, 14 Feb 2019 04:46:15 -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=DuJ6+yAQTOthGAJuFI7z0+3eU377vOz+ej6gIRIiYcY=; b=fdWVp13v9dJnBTNvMny0B1tPEFJE5ccbwKhNicZSjQqKuU2tDbCk7+3YPwdNJMk3tV VXFVvYiPw4s3ruS1qIYc5dcMPL6Vyu607cn7x3e59LISHBiJezTbXX1PQKwlaQEDIy7X 8/Q93CifHC8N8DAaViTSI3GJo44OAoetMkpCOnT9unF8KD8lqXXqmXeIEYsKT4FCNsbr PxaezExU7sbMmXpqV3JU0GoOMgcwkArShKHT0P0ssEIfUrBmLdhHEZjgVdgbgLATQnkj yJy/g0X5QO0t/AOv/aod4ImuXyJLRrx+6dlbpL/f6TbwgPMw490jarazSNXOja/2I82E UCWQ== X-Gm-Message-State: AHQUAuYWZFECuCEBztc1PKKQEGXcUoZ7XMvZQ2DthVEKXPGjkYoqLRtU TwsvM27q0ZpsWZH2ZKP9lPoGHKJ902WikOn6o6zCyWLFiGpmYYP8lJleP/CzfL3yNI4imee+BI8 MOEM6BD8BMglqI5Ih0wXrPDNqyTRYpIjltbFG2UdMrPx7VnzrQsT6XDuswmWB6HEmww== X-Received: by 2002:a17:906:3b8e:: with SMTP id u14mr2693115ejf.130.1550148374533; Thu, 14 Feb 2019 04:46:14 -0800 (PST) X-Google-Smtp-Source: AHgI3IbQSDa54AZlzXmtsWHp7Pp8NEI4hIPzuY5M5DgMgtKw6bavH43uwOGvfLRJN0E8gmM1AtA0 X-Received: by 2002:a17:906:3b8e:: with SMTP id u14mr2693056ejf.130.1550148373577; Thu, 14 Feb 2019 04:46:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550148373; cv=none; d=google.com; s=arc-20160816; b=P0DDHhDAk7KE8FjgkUlPzJq4+LBdj0Madmz7kQ8Xg1kVH9u7kInIgqLM5EiYppwvff UmZ9QQQGAMr4kDdc4t09llnG/0NJmfQts5lZ/o0pFV+cIUnvnCOLZ9YSbGsVMk3ICTD4 X+z9+xmVeconCQcGgegEB6MjUyeg4cSnxDLGIIho8aIunIM2EF5E28fCDoXwRA7A+Dej kgJq30sSrV0r6S3IgnDPwrpOq65VgJ4pACrwXLbo60YC9w1vj9be5pNFzJgSnvMk+Jes gl4Yn2UqrXDwlas1EgxdDHrMip2FSE1nzL0LuExjqzzbljOnp+KMo+StWqIPqK16ejLO NG+w== 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=DuJ6+yAQTOthGAJuFI7z0+3eU377vOz+ej6gIRIiYcY=; b=HYleTYN628NTl4Ie1708wkuHK41F6CqKBB99LHPkhdayXeMyYs96/X4OLOYvbkwuyJ kyEZQxOjEmLqHLvb5JsxwGVO5xHUogklgAznFd5/H9+k2nGnEZUtg7+v2C6yx2CKezdY rXKmI8RkoEV2KMykSgtxL1Pgpq/rythrDQ51vmqfZqGGp1OVhueYY6VqGIT/3ieBEtYM Vr3KB4/GwirNZGBuet4CPCZgjRm4Ps8L9oucUhgMBwui3aYAjRU3BVGVBjp9HbM3ot2a TJ5W3XIIBMWM7VQUaI+9KYe1PR/qYqqkUzA8uqRhISiEd7fXz070a7d9JVb9tZsPRVfB yyJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=wzoNikwP; spf=pass (google.com: domain of peng.fan@nxp.com designates 40.107.0.50 as permitted sender) smtp.mailfrom=peng.fan@nxp.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00050.outbound.protection.outlook.com. [40.107.0.50]) by mx.google.com with ESMTPS id o1-v6si969305ejb.330.2019.02.14.04.46.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 14 Feb 2019 04:46:13 -0800 (PST) Received-SPF: pass (google.com: domain of peng.fan@nxp.com designates 40.107.0.50 as permitted sender) client-ip=40.107.0.50; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector1 header.b=wzoNikwP; spf=pass (google.com: domain of peng.fan@nxp.com designates 40.107.0.50 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=DuJ6+yAQTOthGAJuFI7z0+3eU377vOz+ej6gIRIiYcY=; b=wzoNikwP3SIrrJ7zdUdEwPK8oepSSX5/J55Z+e7TgZ5WAeQx/nWBn24m56Fn1ONEe1LjAfPKw02jas0s6HY+dhxsJWXC1sC4XHedBxSMyKsn4ej+ssWOpJ94+FiUmAaw6BbrZ4Ui5hPs79Ab9jJ6mQou1bKpi/K6ttYqt4pTgDc= Received: from VI1PR04MB4496.eurprd04.prod.outlook.com (20.177.54.92) by VI1PR04MB4814.eurprd04.prod.outlook.com (20.177.48.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1622.16; Thu, 14 Feb 2019 12:45:52 +0000 Received: from VI1PR04MB4496.eurprd04.prod.outlook.com ([fe80::ede0:3ae0:e171:9356]) by VI1PR04MB4496.eurprd04.prod.outlook.com ([fe80::ede0:3ae0:e171:9356%2]) with mapi id 15.20.1601.023; Thu, 14 Feb 2019 12:45:52 +0000 From: Peng Fan To: "akpm@linux-foundation.org" , "labbott@redhat.com" , "mhocko@suse.com" , "vbabka@suse.cz" , "iamjoonsoo.kim@lge.com" , "rppt@linux.vnet.ibm.com" , "m.szyprowski@samsung.com" , "rdunlap@infradead.org" , "andreyknvl@google.com" CC: "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "van.freenix@gmail.com" , Peng Fan Subject: [PATCH] mm/cma: cma_declare_contiguous: correct err handling Thread-Topic: [PATCH] mm/cma: cma_declare_contiguous: correct err handling Thread-Index: AQHUxGM3TWg8yAT7z0a/qrCp1B+TPw== Date: Thu, 14 Feb 2019 12:45:51 +0000 Message-ID: <20190214125704.6678-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: HK2PR06CA0003.apcprd06.prod.outlook.com (2603:1096:202:2e::15) To VI1PR04MB4496.eurprd04.prod.outlook.com (2603:10a6:803:69::28) 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: 29c7f0a3-b96e-4c58-5af5-08d6927a59c4 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600110)(711020)(4605077)(4618075)(2017052603328)(7153060)(7193020);SRVR:VI1PR04MB4814; x-ms-traffictypediagnostic: VI1PR04MB4814: x-microsoft-exchange-diagnostics: =?iso-8859-1?q?1=3BVI1PR04MB4814=3B23=3AuH?= =?iso-8859-1?q?500QrpxOaak7YBvl+tsZHVc+46eP7ZmIe5YsNrQLmrfpHLq3+7p/rm325acZ?= =?iso-8859-1?q?PHt+mwi89UM8qewJXfG7zX7xJ3BmbUlsj1af+CdRwozPFr1/hudOP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+XQ6NLkZVgDnlq/4unWfgniEdrc/bHyDJdL0rF87s2SwyWU0daFRe2?= =?iso-8859-1?q?83oULfQ01e5GEo5+bwQnwSdSacLfyH71GrgAi7hAR5JRavdolPq0BpPMfbl6?= =?iso-8859-1?q?U5R/QFl4CLdjk645W4t9M3k9cUDuG3jIP2khTThbvLHqrIudnzXCvp/XCqJo?= =?iso-8859-1?q?sqJGIqKUnTNjqxV1ubQdZP6GRNHJbheo+r0+Th+3YGaTwsUFVa4un5jVfeqv?= =?iso-8859-1?q?XGqkyZ/0EKr9gQK9482w+7WRWhdKaWEIpIWCAfwQzO02Jc/hfEfXLwG24=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 09480768F8 x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(396003)(366004)(346002)(136003)(376002)(39860400002)(189003)(199004)(1076003)(316002)(97736004)(7736002)(305945005)(86362001)(2201001)(36756003)(2501003)(81156014)(8936002)(8676002)(44832011)(4744005)(2906002)(6486002)(81166006)(6436002)(99286004)(54906003)(68736007)(52116002)(110136005)(50226002)(105586002)(71190400001)(186003)(14444005)(256004)(26005)(486006)(386003)(7416002)(2616005)(106356001)(4326008)(14454004)(66066001)(71200400001)(476003)(53936002)(3846002)(6116002)(25786009)(6506007)(478600001)(102836004)(6512007);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR04MB4814;H:VI1PR04MB4496.eurprd04.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A: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: gg5BTYDNSODyetnGhGe8qqwttf+oufqTLqeDhtstjb296TiL2WJXaYrZtCjSCTfQotoVvERW6aJZYBP8rLk2M+qtHHhp/TVTdD3GC2+4mZG2WZLjfJC5prpVgid/2rvxdy3ZZsAIkzB6pXgEHCQNp03Ojw2RBSQVAiax1eszsdmjRLFcmSgstEzYRqwn9NFL5GszGoDgf+JjHAW/khSv6GnP3wkJz9PxIbJ2p42Gv+m6q/pJkjVrUQ2E66+IKrNsxHhdUPNxDsSSY3N0lnshxSKgsOZ4/x4g4cvKGYb18yo3hKj9KmBGj3PHbs9jjzfkqso7joxWns6wcwftVayYt0AU4JYmaqVRQ4BcnDD5wmb1/GXWkNBeY+DY5oYPE5Fd2OOyQmOlOaTIsxbqdshqn5iEUsl5j+NIlKQrJ7G5Nt4= MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 29c7f0a3-b96e-4c58-5af5-08d6927a59c4 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2019 12:45:46.8381 (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: VI1PR04MB4814 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. Signed-off-by: Peng Fan Reviewed-by: Catalin Marinas --- 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;