Received: by 2002:a05:7412:4e10:b0:e2:908c:2ebd with SMTP id gb16csp45311rdb; Mon, 6 Nov 2023 23:24:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGPELiT2e0rN9Yk3eVEYA20In4zxTvD7ggC1r6hwAzdbA+yKuqQBsKAk/NBYK7d8o8KYJUN X-Received: by 2002:a05:6a20:3d82:b0:16b:9886:7eda with SMTP id s2-20020a056a203d8200b0016b98867edamr36915041pzi.35.1699341842154; Mon, 06 Nov 2023 23:24:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699341842; cv=none; d=google.com; s=arc-20160816; b=i++2UlMlcTiE9wYJY66JqVM0cMMrST2Xcyim6iw2YWfn1tORq8Jv6966HxsN+6GtfV tXVeHRLcPwIep4SpmGPpKraQFXsdujQENEyV+7H9jOXIEWyslhv8Fuenc8PuyLNLFovc dYzNdbQe6Itq5YQKSFAgiN3Lsnp/jA2DjrpYdN05lxkQ3y7ynbrPL20OpQ4wM3rTH4N9 yrm6gqGhzCT+onasrmqVLAgSU1Ewopj3HrQ0WG8slC6CHtfcZU0bMsW7m+iXE8KMSVQi chZ3ICaxGULnzE+3DhumWnQeBkW7azqAx2NrVmnQgBCPfVQd9waScdXlru+cTXvhHYjJ 2SVg== 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=1G6e7866hFT/kF3Bw82Ml+XB+OH9nS4569IdHqqJRiE=; fh=BRM9adDpw0s2XdxhvCXYHzLndr+pnVNzNHDHzDMP52Y=; b=W3apqng6G+tK27va7YQX1PcjDtdd3kmXXU3rCQd85/pY+BaNshmWq5DlEM6EkbR0pI qyhyqq6P3OqFv39SLdNPfWRABAYkqTSJVEmWPh5lDaGN68TcxGH0VWHcl3Kx7/DqEcqy zrpOkwvuD+Rw0kipi2+s6kh1F2jK+9+4mX2VMP14xDJESSJWdLOeHEonWFOad2UP2v5d +4glD8kR1HKDqgJiSnexDY5NCOhJfH6vnozR686AlgFvwfoeMIjw+Pd/AAcFRwek+i5X 6Tzh7OCS+4dQUZM8clte0yWsa7gOqduy0Bfl2mzJVRgzqK/jxt5uYgPcwUpdxb2n/pkN vUNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HiUaRcaT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id a16-20020a170902ecd000b001c752577582si10794354plh.359.2023.11.06.23.24.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 23:24:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=HiUaRcaT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 17F6C802E8BD; Mon, 6 Nov 2023 23:23:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233595AbjKGHXW (ORCPT + 99 others); Tue, 7 Nov 2023 02:23:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233481AbjKGHXU (ORCPT ); Tue, 7 Nov 2023 02:23:20 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33CA4C6; Mon, 6 Nov 2023 23:23:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699341798; x=1730877798; h=from:date:subject:mime-version:content-transfer-encoding: message-id:references:in-reply-to:to:cc; bh=HZM5+hBI5lAioW4CqYpnGoymfhCO2XjBgbEz0jWhomc=; b=HiUaRcaTM7225K4ENsGwSW3zEaffQme35HJZzgfCb1m4q1piW1tkaRCP NhYonyDavNUxFE8e4SLwGddv9sPGKjSGCF44KVpB4I93nHVgrurZkxjoF WIY8G7uUOOckiGXJBha5uUFFQ1gml3X2VZoKo1n2Jqs5OV0mg8B6on+Eh o+88NWuDloFZcQ1uRSp5UOBaMxLX1oPmGQsnF9+oY6HzVZiAXjpNImbQ2 iGnsR2zkV3MMSyZS9mz3eQlpA37V/LszN4Y44AZONp4Fql6UUXqQUz/R3 28vMiEDHe3iO+WakLg2gIxbcTBIPAir/ouYhpKGhwhBqnLaOZzZZdHYjy Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10886"; a="475689634" X-IronPort-AV: E=Sophos;i="6.03,282,1694761200"; d="scan'208";a="475689634" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 23:23:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10886"; a="712477221" X-IronPort-AV: E=Sophos;i="6.03,282,1694761200"; d="scan'208";a="712477221" Received: from pengmich-mobl1.amr.corp.intel.com (HELO [192.168.1.200]) ([10.212.96.119]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Nov 2023 23:23:15 -0800 From: Vishal Verma Date: Tue, 07 Nov 2023 00:22:41 -0700 Subject: [PATCH v10 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: <20231107-vv-kmem_memmap-v10-1-1253ec050ed0@intel.com> References: <20231107-vv-kmem_memmap-v10-0-1253ec050ed0@intel.com> In-Reply-To: <20231107-vv-kmem_memmap-v10-0-1253ec050ed0@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 , Fan Ni X-Mailer: b4 0.13-dev-26615 X-Developer-Signature: v=1; a=openpgp-sha256; l=1434; i=vishal.l.verma@intel.com; h=from:subject:message-id; bh=HZM5+hBI5lAioW4CqYpnGoymfhCO2XjBgbEz0jWhomc=; b=owGbwMvMwCXGf25diOft7jLG02pJDKmeTx/u2KMpofzhr339p/4ulhoHJrGPXanCC7+ECHxYL X9h51uhjlIWBjEuBlkxRZa/ez4yHpPbns8TmOAIM4eVCWQIAxenAEzk3ByG/9mrWwovZp29Ejbz qvedaOUILZP3Ti4Hb8oszGwJtNc+ncnwz3Bv9Z3235/C8n54lB/yKZB+U/r7tc0txUARf/dFErv fcwMA X-Developer-Key: i=vishal.l.verma@intel.com; a=openpgp; fpr=F8682BE134C67A12332A2ED07AFA61BEA3B84DFF X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email 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 (fry.vger.email [0.0.0.0]); Mon, 06 Nov 2023 23:23:52 -0800 (PST) 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 Reviewed-by: Fan Ni 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 ab41a511e20a..3ed48059a780 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1439,13 +1439,13 @@ 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) { ret = -ENOMEM; goto error; } - - memcpy(params.altmap, &mhp_altmap, sizeof(mhp_altmap)); } /* fallback to not using altmap */ } -- 2.41.0