Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3919923pxb; Tue, 10 Nov 2020 03:38:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4DQRUfhw95D+V4CIloEo/GbfzBoOtYmFxAF+IuRiRhIZRHeXVmL7wjTaVDPd31FYdCJT3 X-Received: by 2002:a17:906:3fc5:: with SMTP id k5mr20090174ejj.158.1605008292369; Tue, 10 Nov 2020 03:38:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605008292; cv=none; d=google.com; s=arc-20160816; b=mYVC8jSpHhQB8IiyBo3rEaqTe0QpXvWAuUpevQ3KcrIPN59v8RptXB/DeyvA/Wv2j5 47nK/lpgoiHoCKvMwA30ovTfppmTb8Vjl1COUI3KC02Cwk1EaB66nMZYdPTGa/1qWT9O ICh8tPTOS55fPmpOpb1Wzt6/jMmftW9/7FtUGzj+OGKPHvJ85zZAVGt86UUkreFAHFv1 tqAU2CuGK8rb0/Yk45EReWQ6PTZfKS7cOT+1C6hU3/tEewrJw7lZGug+1WZJixgGYkJB FZ7c0IRpd0yj/WzoRx8I2JPFDtWY86sJUJE3JUCE6Y0IBBCddGLne6/xWqiFLGsnTeia VbOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:to:from; bh=0k4KPGLtT6/z4YOxKmIi7nalEWVXjsmASoZf0wlt6zw=; b=kef5ndqGMI3ExTLuLfdzDrMdLDuPxa3S5SzNeg1YJa3wr8gmRoDQJgtCV4dkaIIIzj GEe64uI59cuK4du2KQ7KpSMGrF+IXKX2S8UV650XOhwSgcZq2Ok0yYyOuW6KjuRI4A5F /SaTL1MtGR6SqS6NhSDUhqdP1HaudCakbXM1rys4ZNYUMgRO/kirQHgFqFuAPt1bgZcQ Xj6oxnYUecNEvf55ZAjKZMwhusgf+iG5kZEUX4favHOM/p985VYz/YTUQHd0z51a/b8d dE18bwIThqVqUI8AQP6xrjXLA/i4m0FVsHZZ/cAwU1ScckMqq0kmUSPK0oDe6W2IgEID Xjnw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id om24si8867595ejb.235.2020.11.10.03.37.37; Tue, 10 Nov 2020 03:38:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728478AbgKJLek (ORCPT + 99 others); Tue, 10 Nov 2020 06:34:40 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:7201 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726152AbgKJLek (ORCPT ); Tue, 10 Nov 2020 06:34:40 -0500 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CVm3f60yCzkhsd; Tue, 10 Nov 2020 19:34:22 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.487.0; Tue, 10 Nov 2020 19:34:28 +0800 From: Tian Tao To: , , , , , , , , , Subject: [PATCH] drm/amd/pm: Use kmemdup instead of kmalloc and memcpy Date: Tue, 10 Nov 2020 19:34:58 +0800 Message-ID: <1605008098-33391-1-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fixes coccicheck warning: drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c:255: 36-43: WARNING opportunity for kmemdup Signed-off-by: Tian Tao --- drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c index 740e2fc..1e79baa 100644 --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega12_processpptables.c @@ -252,12 +252,11 @@ static int init_powerplay_table_information( phm_copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_max, powerplay_table->PowerSavingClockMax, ATOM_VEGA12_PPCLOCK_COUNT); phm_copy_clock_limits_array(hwmgr, &pptable_information->power_saving_clock_min, powerplay_table->PowerSavingClockMin, ATOM_VEGA12_PPCLOCK_COUNT); - pptable_information->smc_pptable = kmalloc(sizeof(PPTable_t), GFP_KERNEL); + pptable_information->smc_pptable = kmemdup(&(powerplay_table->smcPPTable), + sizeof(PPTable_t), GFP_KERNEL); if (pptable_information->smc_pptable == NULL) return -ENOMEM; - memcpy(pptable_information->smc_pptable, &(powerplay_table->smcPPTable), sizeof(PPTable_t)); - result = append_vbios_pptable(hwmgr, (pptable_information->smc_pptable)); return result; -- 2.7.4