Received: by 2002:a05:7412:b795:b0:e2:908c:2ebd with SMTP id iv21csp29819rdb; Wed, 1 Nov 2023 15:52:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGveihY3gCEwYg8Z/LJb7gtMevJEviQKge6rZssDD+ZyRiQccpO91P8uzy7qlnb27wB+Hfm X-Received: by 2002:a05:6a20:734f:b0:155:1710:664a with SMTP id v15-20020a056a20734f00b001551710664amr10315821pzc.18.1698879179086; Wed, 01 Nov 2023 15:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698879179; cv=none; d=google.com; s=arc-20160816; b=KFIGxKuGYe+O8IJv5VgMiT02Nz1VM2XYBtUKnjkAi5UEZRgLFsKfUMxILUZx/HRk39 TB7rMR7Rt1TENQTyTky2zE9BjhrtZnCzn1+xmjXx0noIQI+GyQeMq9s1doeieOe+0Sy4 eFJsXYZZ12Myp9mJuHCyEcvFMAToHp9iE93+ROJMaVf+eNHB490X+LjMo52ttANkw+LA OER+xJuNDQWXjjxg84M5pd/6G43ib6CnEbG1sZPilCH5utvK9ELM/3Jz8s0Czmgqcd/Q 6gHD4kKSWym3kxVzBmeplAzvs0MBMvGhLMWDPXgcJ1E0IJOm5ub0g8rYJG3OBlqCGl7g KXxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=zzMhYvJnkemfZMH9qCM5Cd7iPomAieby6YrwPqfCLLk=; fh=ZJyl7lGIgKsdPRNZ+hASCGqYu4kS00HsOWlg75WSZ6w=; b=tdvgLLIWveCoTb4Byl9PqfCa4IGLf1TfmIhN/fsA9xi5nCpb79gcLc27/69eIVUNaT uphEW2w3R4/thGBk2c0RmmYLNHrDil6jOeDG20U6PRg/9Nvi6S+wISiaZgFBBx8BxwLA ixkjoWrzKIlrI9S9KgbE5L49qYx/QJDj+iAc8+dTjrSmpYfDUhF/CuVMtcHERmmew7zu coYxKGDUedcmkYFF2uoSIV2chH8UV9y+LlAGI/Kdfx7w1+JUN+VLQoISZdM9WR+7IGiN kLuuKlfbeBEW6Ee7urNZn4VOArRaB9SxHhxINAbgCuiMTyqUrx7Q+leAOj6uLFKMfTwF iO1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fvEOmbMm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id f2-20020a056a0022c200b006935df3019esi2525460pfj.235.2023.11.01.15.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Nov 2023 15:52:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=fvEOmbMm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id AB4F481A1E9E; Wed, 1 Nov 2023 15:52:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347154AbjKAWwj (ORCPT + 99 others); Wed, 1 Nov 2023 18:52:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36368 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229445AbjKAWwd (ORCPT ); Wed, 1 Nov 2023 18:52:33 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0A0B119; Wed, 1 Nov 2023 15:52:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698879145; x=1730415145; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=hEIpF+H2iWRMoZGPvwzbL8B1g/l212Q9ts7SomwLAKg=; b=fvEOmbMmdgYhC6FE2kN+5ngwMn8Ai1mCbY+7TVqSo8lU2IET4B99q9fb QjAJbMnnNCl8WvEXXgUnOpR976ZYCLLwtrnz5OZ98NjgyxAzmJXYYqowA xtApK2d+xD/9RnMeYyfmQAIDjwWh1EXVNulRLO1PGWCyGYWvp8qgcBGd6 NXkzG90VuXlNT8QFM0UvSxl7ne9plaPxQfqaDtL61u7VCdDlFKrrBPdco I69Aq9S6zgMW9f5mBrgGBnapymq0IutM0TPDvsTLABzp4aC6d2xEmJGM6 jpX1h8xya3kvqCj6XTgcXb5scjjQMU8l3D/evahU3PS2FCcMiy9qRlSP/ Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="10133607" X-IronPort-AV: E=Sophos;i="6.03,269,1694761200"; d="scan'208";a="10133607" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 15:52:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10881"; a="796033557" X-IronPort-AV: E=Sophos;i="6.03,269,1694761200"; d="scan'208";a="796033557" Received: from dgopalan-mobl.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.98.103]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Nov 2023 15:52:22 -0700 From: Vishal Verma Date: Wed, 01 Nov 2023 16:51:51 -0600 Subject: [PATCH v8 1/3] mm/memory_hotplug: replace an open-coded kmemdup() in add_memory_resource() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20231101-vv-kmem_memmap-v8-1-5e4a83331388@intel.com> References: <20231101-vv-kmem_memmap-v8-0-5e4a83331388@intel.com> In-Reply-To: <20231101-vv-kmem_memmap-v8-0-5e4a83331388@intel.com> To: Andrew Morton , David Hildenbrand , Oscar Salvador , Dan Williams , Dave Jiang Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org, Huang Ying , Dave Hansen , "Aneesh Kumar K.V" , Michal Hocko , Jonathan Cameron , Jeff Moyer , Vishal Verma X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=openpgp-sha256; l=1362; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=hEIpF+H2iWRMoZGPvwzbL8B1g/l212Q9ts7SomwLAKg=; b=owGbwMvMwCXGf25diOft7jLG02pJDKlO15aG/1KINNWN2ie9r25S157UB9UxN8TOaWyxuKfd8 6hBxsyuo5SFQYyLQVZMkeXvno+Mx+S25/MEJjjCzGFlAhnCwMUpABNhecXwV47p9dUwJv3W+3aV IXtYrjVW8cQ+C77ucvhiidbLafbvFjEyPJQoOd3km/jN6fxxuX8PJ6VO8QkrNSvJWn/FSjhXzS6 dBQA= X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 01 Nov 2023 15:52:46 -0700 (PDT) A review of the memmap_on_memory modifications to add_memory_resource() revealed an instance of an open-coded kmemdup(). Replace it with kmemdup(). Cc: Andrew Morton Cc: David Hildenbrand Cc: Michal Hocko Cc: Oscar Salvador Cc: Dan Williams Reported-by: Dan Williams Reviewed-by: David Hildenbrand Signed-off-by: Vishal Verma --- mm/memory_hotplug.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index f8d3e7427e32..6be7de9efa55 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1439,11 +1439,11 @@ int __ref add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags) if (mhp_flags & MHP_MEMMAP_ON_MEMORY) { if (mhp_supports_memmap_on_memory(size)) { mhp_altmap.free = memory_block_memmap_on_memory_pages(); - params.altmap = kmalloc(sizeof(struct vmem_altmap), GFP_KERNEL); + params.altmap = kmemdup(&mhp_altmap, + sizeof(struct vmem_altmap), + GFP_KERNEL); if (!params.altmap) goto error; - - memcpy(params.altmap, &mhp_altmap, sizeof(mhp_altmap)); } /* fallback to not using altmap */ } -- 2.41.0