Skip to contentSkip to conversation

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

PATCH In review Dan Carpenter 2 participants 3 messages Feb 16, 2021 – Feb 17, 2021

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

PATCH 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")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c     | 4 +++-
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 1 +
 2 files changed, 4 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);
drivers/gpu/drm/nouveau/nouveau_backlight.c +1 -0
index 72f35a2babcb..3786b1c85182 100644
@@ -274,6 +274,7 @@ nouveau_backlight_init(struct drm_connector *connector)
 
 	if (!nouveau_get_backlight_name(backlight_name, bl)) {
 		NV_ERROR(drm, "Failed to retrieve a unique name for the backlight interface\n");
+		ret = -ENOMEM;
 		goto fail_alloc;
 	}
 
Signature · 6 lines
2.30.0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#1 lore raw
Quoted 32 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")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c     | 4 +++-
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 1 +
 2 files changed, 4 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);
drivers/gpu/drm/nouveau/nouveau_backlight.c +0 -0
index 72f35a2babcb..3786b1c85182 100644

drivers/gpu/drm/nouveau/nouveau_backlight.c nouveau_backlight_init(struct drm_connector *connector) · line 279

Quoted 6 lines
drivers/gpu/drm/nouveau/nouveau_backlight.c +1 -0
@@ -274,6 +274,7 @@ nouveau_backlight_init(struct drm_connector *connector)
 
        if (!nouveau_get_backlight_name(backlight_name, bl)) {
                NV_ERROR(drm, "Failed to retrieve a unique name for the backlight interface\n");
+               ret = -ENOMEM;
                goto fail_alloc;
        }

This hunk looks unrelated?

Alex

Quoted 8 lines
drivers/gpu/drm/nouveau/nouveau_backlight.c +0 -1
--

2.30.0

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

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

#2 lore raw
Quoted 34 lines · Alex Deucher
Quoted 33 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")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pmu.c     | 4 +++-
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 1 +
 2 files changed, 4 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);
drivers/gpu/drm/nouveau/nouveau_backlight.c +0 -0
index 72f35a2babcb..3786b1c85182 100644
@@ -274,6 +274,7 @@ nouveau_backlight_init(struct drm_connector *connector)
 
Quoted 8 lines

drivers/gpu/drm/nouveau/nouveau_backlight.c nouveau_backlight_init(struct drm_connector *connector) · line 279

Quoted 5 lines
drivers/gpu/drm/nouveau/nouveau_backlight.c +1 -0
        if (!nouveau_get_backlight_name(backlight_name, bl)) {
                NV_ERROR(drm, "Failed to retrieve a unique name for the backlight interface\n");
+               ret = -ENOMEM;
                goto fail_alloc;
        }

This hunk looks unrelated?

That's so weird... I don't even have any clue how that would happen at all.. Weee wooo weee woooo ALIENS!

Anyway, I'll resend. Thanks!

regards,
dan carpenter

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