From patchwork Tue Aug 15 09:24:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinjie Ruan X-Patchwork-Id: 13353681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8C45CC0015E for ; Tue, 15 Aug 2023 09:25:36 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.583941.914288 (Exim 4.92) (envelope-from ) id 1qVqIh-0001cR-TW; Tue, 15 Aug 2023 09:25:19 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 583941.914288; Tue, 15 Aug 2023 09:25:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qVqIh-0001cK-Qn; Tue, 15 Aug 2023 09:25:19 +0000 Received: by outflank-mailman (input) for mailman id 583941; Tue, 15 Aug 2023 09:25:18 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1qVqIg-0001cE-AU for xen-devel@lists.xenproject.org; Tue, 15 Aug 2023 09:25:18 +0000 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a21d561f-3b4d-11ee-8774-cb3800f73035; Tue, 15 Aug 2023 11:25:15 +0200 (CEST) Received: from kwepemi500008.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RQ5Rj3PmRzrSWM; Tue, 15 Aug 2023 17:23:45 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemi500008.china.huawei.com (7.221.188.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Tue, 15 Aug 2023 17:25:04 +0800 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a21d561f-3b4d-11ee-8774-cb3800f73035 From: Ruan Jinjie To: , Juergen Gross , Stefano Stabellini , Oleksandr Tyshchenko CC: Subject: [PATCH -next] xen: Switch to use kmemdup() helper Date: Tue, 15 Aug 2023 17:24:34 +0800 Message-ID: <20230815092434.1206386-1-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.90.53.73] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500008.china.huawei.com (7.221.188.139) X-CFilter-Loop: Reflected Use kmemdup() helper instead of open-coding to simplify the code. Signed-off-by: Ruan Jinjie Reviewed-by: Juergen Gross --- drivers/xen/xen-acpi-processor.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/xen/xen-acpi-processor.c b/drivers/xen/xen-acpi-processor.c index 9cb61db67efd..e4be543987a5 100644 --- a/drivers/xen/xen-acpi-processor.c +++ b/drivers/xen/xen-acpi-processor.c @@ -473,11 +473,8 @@ static int xen_upload_processor_pm_data(void) if (!_pr) continue; - if (!pr_backup) { - pr_backup = kzalloc(sizeof(struct acpi_processor), GFP_KERNEL); - if (pr_backup) - memcpy(pr_backup, _pr, sizeof(struct acpi_processor)); - } + if (!pr_backup) + pr_backup = kmemdup(_pr, sizeof(struct acpi_processor), GFP_KERNEL); (void)upload_pm_data(_pr); }