From patchwork Sat Mar 2 06:50:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 10836505 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 E6E341515 for ; Sat, 2 Mar 2019 06:51:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C40882CA08 for ; Sat, 2 Mar 2019 06:51:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2FC62CAEA; Sat, 2 Mar 2019 06:51:02 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4AA4B2CA08 for ; Sat, 2 Mar 2019 06:51:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 619446E35E; Sat, 2 Mar 2019 06:50:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by gabe.freedesktop.org (Postfix) with ESMTPS id 62D046E35E for ; Sat, 2 Mar 2019 06:50:58 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.58,430,1544482800"; d="scan'208";a="371596198" Received: from abo-58-107-68.mrs.modulonet.fr (HELO hadrien) ([85.68.107.58]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Mar 2019 07:50:36 +0100 Date: Sat, 2 Mar 2019 07:50:36 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Likun Gao Subject: [PATCH] drm/amd/powerplay: fix memdup.cocci warnings Message-ID: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kbuild test robot , David Airlie , Kevin Wang , amd-gfx@lists.freedesktop.org, Huang Rui , dri-devel@lists.freedesktop.org, Alex Deucher , Evan Quan , =?iso-8859-15?q?Christian_K=F6nig?= , kbuild-all@01.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: kbuild test robot Simplify the code a bit by using kmemdup instead of kzalloc and memcpy. Generated by: scripts/coccinelle/api/memdup.cocci Fixes: 76760fe3c00d ("drm/amd/powerplay: add function to store overdrive information for smu11") CC: Likun Gao Signed-off-by: kbuild test robot Signed-off-by: Julia Lawall Reviewed-by: Likun Gao Signed-off-by: kbuild test robot Signed-off-by: Julia Lawall Acked-by: Huang Rui --- tree: git://people.freedesktop.org/~agd5f/linux.git drm-next-5.2-wip head: 25752e1fc83e9f983b11d680fc7bfc129b4eaae6 commit: 76760fe3c00d04f25cc1a6115294310d4effeb77 [161/226] drm/amd/powerplay: add function to store overdrive information for smu11 :::::: branch date: 6 hours ago :::::: commit date: 6 hours ago vega20_ppt.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c +++ b/drivers/gpu/drm/amd/amdgpu/../powerplay/vega20_ppt.c @@ -173,14 +173,12 @@ static int vega20_setup_od8_information( if (table_context->od_feature_capabilities) return -EINVAL; - table_context->od_feature_capabilities = kzalloc(od_feature_array_size, GFP_KERNEL); + table_context->od_feature_capabilities = kmemdup(&powerplay_table->OverDrive8Table.ODFeatureCapabilities, + od_feature_array_size, + GFP_KERNEL); if (!table_context->od_feature_capabilities) return -ENOMEM; - memcpy(table_context->od_feature_capabilities, - &powerplay_table->OverDrive8Table.ODFeatureCapabilities, - od_feature_array_size); - /* Setup correct ODSettingCount, and store ODSettingArray from * powerplay table to od_settings_max and od_setting_min */ od_setting_count = @@ -194,7 +192,9 @@ static int vega20_setup_od8_information( if (table_context->od_settings_max) return -EINVAL; - table_context->od_settings_max = kzalloc(od_setting_array_size, GFP_KERNEL); + table_context->od_settings_max = kmemdup(&powerplay_table->OverDrive8Table.ODSettingsMax, + od_setting_array_size, + GFP_KERNEL); if (!table_context->od_settings_max) { kfree(table_context->od_feature_capabilities); @@ -202,14 +202,12 @@ static int vega20_setup_od8_information( return -ENOMEM; } - memcpy(table_context->od_settings_max, - &powerplay_table->OverDrive8Table.ODSettingsMax, - od_setting_array_size); - if (table_context->od_settings_min) return -EINVAL; - table_context->od_settings_min = kzalloc(od_setting_array_size, GFP_KERNEL); + table_context->od_settings_min = kmemdup(&powerplay_table->OverDrive8Table.ODSettingsMin, + od_setting_array_size, + GFP_KERNEL); if (!table_context->od_settings_min) { kfree(table_context->od_feature_capabilities); @@ -218,10 +216,6 @@ static int vega20_setup_od8_information( table_context->od_settings_max = NULL; return -ENOMEM; } - - memcpy(table_context->od_settings_min, - &powerplay_table->OverDrive8Table.ODSettingsMin, - od_setting_array_size); } return 0;