aboutsummaryrefslogtreecommitdiffstats
path: root/common/recipes-kernel/linux/linux-yocto-4.19.8/1556-drm-amd-powerplay-fix-memdup.cocci-warnings.patch
blob: 0ed7e757fb5051a2109704566f1d094625bdd6bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
From 29b6d9690c035d93b5f8863a0667fcb19dbbe435 Mon Sep 17 00:00:00 2001
From: kbuild test robot <fengguang.wu@intel.com>
Date: Sat, 2 Mar 2019 07:50:36 +0100
Subject: [PATCH 1556/2940] drm/amd/powerplay: fix memdup.cocci warnings

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 <Likun.Gao@amd.com>
Reviewed-by: Likun Gao <Likun.Gao@amd.com>
Acked-by: Huang Rui <ray.huang@amd.com>
Signed-off-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
---
 drivers/gpu/drm/amd/powerplay/vega20_ppt.c | 24 ++++++++--------------
 1 file changed, 9 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
index f7188a7fb194..c66ad3b223d3 100644
--- a/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
+++ b/drivers/gpu/drm/amd/powerplay/vega20_ppt.c
@@ -204,14 +204,12 @@ static int vega20_setup_od8_information(struct smu_context *smu)
 		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 =
@@ -225,7 +223,9 @@ static int vega20_setup_od8_information(struct smu_context *smu)
 		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);
@@ -233,14 +233,12 @@ static int vega20_setup_od8_information(struct smu_context *smu)
 			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);
@@ -249,10 +247,6 @@ static int vega20_setup_od8_information(struct smu_context *smu)
 			table_context->od_settings_max = NULL;
 			return -ENOMEM;
 		}
-
-		memcpy(table_context->od_settings_min,
-		       &powerplay_table->OverDrive8Table.ODSettingsMin,
-		       od_setting_array_size);
 	}
 
 	return 0;
-- 
2.17.1