Skip to contentSkip to conversation

Revert "drm/nouveau/acr: Fix undefined behavior in nvkm_acr_hsfw_load_bl()"

PATCH In review Lyude Paul 2 participants 3 messages Jan 28, 2022 – Jan 29, 2022

Subsystems (3)
lore
Share & tools
lore

Lyude Paul

author maintainer
#0 lore raw

PATCH 1/1 Revert "drm/nouveau/acr: Fix undefined behavior in nvkm_acr_hsfw_load_bl()"

This reverts commit 2343bcdb4747d4f418a4daf2e898b94f86c24a59.

Unfortunately, as Greg pointed out I totally missed the fact that this patch came from a umn.edu patch. umn.edu is still banned from contributing to the Linux kernel, so let's revert this for the time being. I'll re-evaluate this fix myself later and send another fix if this ends up being valid.

Cc Greg KH <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Karol Herbst <[email protected]>
---
 drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c +4 -5
index a6ea89a5d51a..667fa016496e 100644
@@ -142,12 +142,11 @@ nvkm_acr_hsfw_load_bl(struct nvkm_acr *acr, const char *name, int ver,
 
 	hsfw->imem_size = desc->code_size;
 	hsfw->imem_tag = desc->start_tag;
-	hsfw->imem = kmemdup(data + desc->code_off, desc->code_size, GFP_KERNEL);
+	hsfw->imem = kmalloc(desc->code_size, GFP_KERNEL);
+	memcpy(hsfw->imem, data + desc->code_off, desc->code_size);
+
 	nvkm_firmware_put(fw);
-	if (!hsfw->imem)
-		return -ENOMEM;
-	else
-		return 0;
+	return 0;
 }
 
 int
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

on further reconsideration: Self-NAKing this. I don't see any issues with those patches.

Quoted 40 lines · Lyude Paul

This reverts commit 2343bcdb4747d4f418a4daf2e898b94f86c24a59.

Unfortunately, as Greg pointed out I totally missed the fact that this patch came from a umn.edu patch. umn.edu is still banned from contributing to the Linux kernel, so let's revert this for the time being. I'll re-evaluate this fix myself later and send another fix if this ends up being valid.

Cc Greg KH <[email protected]>
Cc Ben Skeggs <[email protected]>
Cc Karol Herbst <[email protected]>

---
 drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c | 9 ++++-----

 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/gpu/drm/nouveau/nvkm/subdev/acr/hsfw.c +0 -0
index a6ea89a5d51a..667fa016496e 100644
@@ -142,12 +142,11 @@ nvkm_acr_hsfw_load_bl(struct nvkm_acr *acr, const char
 *name, int ver,


        hsfw->imem_size = desc->code_size;
        hsfw->imem_tag = desc->start_tag;
-       hsfw->imem = kmemdup(data + desc->code_off, desc->code_size, GFP_KERNEL);
+       hsfw->imem = kmalloc(desc->code_size, GFP_KERNEL); +       memcpy(hsfw->imem, data + desc->code_off, desc->code_size); +
        nvkm_firmware_put(fw);
-       if (!hsfw->imem)
-               return -ENOMEM;
-       else
-               return 0;
+       return 0;
 }

 int

Signature · 3 lines
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat
#2 lore raw
Quoted 2 lines · Lyude Paul

on further reconsideration: Self-NAKing this. I don't see any issues with those patches.

I agree, the original change looks correct here. Thanks for the re-review.

greg k-h