Skip to contentSkip to conversation

drm/amdgpu: fix an error code in init_pmu_entry_by_type_and_add()

PATCH Applied Dan Carpenter 2 participants 2 messages Apr 14, 2021 – Apr 15, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/amdgpu: fix an error code in init_pmu_entry_by_type_and_add()

If the kmemdup() fails then this should return a negative error code but it currently returns success

Fixes b4a7db71ea06 ("drm/amdgpu: add per device user friendly xgmi events for vega20")

---
v2: I sent this patch in Feb but I accidentally added an unrelated hunk from nouveau to the commit. Now both hunks are have been sent to the correct lists.

 drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c +3 -1
index 19c0a3655228..82e9ecf84352 100644
@@ -519,8 +519,10 @@ static int init_pmu_entry_by_type_and_add(struct amdgpu_pmu_entry *pmu_entry,
 	pmu_entry->pmu.attr_groups = kmemdup(attr_groups, sizeof(attr_groups),
 								GFP_KERNEL);
 
-	if (!pmu_entry->pmu.attr_groups)
+	if (!pmu_entry->pmu.attr_groups) {
+		ret = -ENOMEM;
 		goto err_attr_group;
+	}
 
 	snprintf(pmu_name, PMU_NAME_SIZE, "%s_%d", pmu_entry->pmu_file_prefix,
 				adev_to_drm(pmu_entry->adev)->primary->index);
Signature · 6 lines
2.30.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Applied
#1 lore raw
Quoted 6 lines · Dan Carpenter

If the kmemdup() fails then this should return a negative error code but it currently returns success

Fixes b4a7db71ea06 ("drm/amdgpu: add per device user friendly xgmi events for vega20")

Applied. Thanks!

Alex

Quoted 31 lines

---
v2: I sent this patch in Feb but I accidentally added an unrelated hunk from nouveau to the commit. Now both hunks are have been sent to the correct lists.

 drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c +3 -2
index 19c0a3655228..82e9ecf84352 100644
@@ -519,8 +519,10 @@ static int init_pmu_entry_by_type_and_add(struct amdgpu_pmu_entry *pmu_entry,
        pmu_entry->pmu.attr_groups = kmemdup(attr_groups, sizeof(attr_groups),
                                                                GFP_KERNEL);
 
-       if (!pmu_entry->pmu.attr_groups)
+       if (!pmu_entry->pmu.attr_groups) {
+               ret = -ENOMEM;
                goto err_attr_group;
+       }
 
        snprintf(pmu_name, PMU_NAME_SIZE, "%s_%d", pmu_entry->pmu_file_prefix,
                                adev_to_drm(pmu_entry->adev)->primary->index);
--

2.30.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx