Skip to contentSkip to conversation

drm/amdgpu: fix potential NULL pointer when check_atom_bios() fails

PATCH In review Jiawei Gu 2 participants 2 messages Dec 31, 2020 – Jan 3, 2021

Subsystems (2)
lore
Share & tools
lore

Jiawei Gu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix potential NULL pointer when check_atom_bios() fails

Asic funcs pointer needs being checked whether is NULL. Because when check_atom_bios() fails in req_init_data handshake, asic funcs pointer is not initialized yet.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +3 -2
index 6333cada1e09..efdf639f6593 100644
@@ -155,7 +155,7 @@ static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev)
 	u8 header[AMD_VBIOS_SIGNATURE_END+1] = {0};
 	int len;
 
-	if (!adev->asic_funcs->read_bios_from_rom)
+	if (!adev->asic_funcs || !adev->asic_funcs->read_bios_from_rom)
 		return false;
 
 	/* validate VBIOS signature */
@@ -348,7 +348,8 @@ static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev)
 	if (adev->flags & AMD_IS_APU)
 		return igp_read_bios_from_vram(adev);
 	else
-		return amdgpu_asic_read_disabled_bios(adev);
+		return (!adev->asic_funcs || !adev->asic_funcs->read_disabled_bios) ?
+			false : amdgpu_asic_read_disabled_bios(adev);
 }
 
 #ifdef CONFIG_ACPI
Signature · 6 lines
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Acked-by on v1 1/1
#1 lore raw

Am 31.12.20 um 09:47 schrieb Jiawei Gu:

Quoted 3 lines

Asic funcs pointer needs being checked whether is NULL. Because when check_atom_bios() fails in req_init_data handshake, asic funcs pointer is not initialized yet.

Mhm, I'm wondering if we shouldn't change the init sequence then. The asic_funcs is something pretty fundamental.

Quoted 1 line
Quoted 18 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c | 5 +++--
  1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +1 -1
index 6333cada1e09..efdf639f6593 100644
@@ -155,7 +155,7 @@ static bool amdgpu_read_bios_from_rom(struct amdgpu_device *adev)
  	u8 header[AMD_VBIOS_SIGNATURE_END+1] = {0};
  	int len;
 
-	if (!adev->asic_funcs->read_bios_from_rom)
+	if (!adev->asic_funcs || !adev->asic_funcs->read_bios_from_rom)
  		return false;
 
  	/* validate VBIOS signature */

drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev) · line 355

Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c +2 -1
@@ -348,7 +348,8 @@ static bool amdgpu_read_disabled_bios(struct amdgpu_device *adev)
  	if (adev->flags & AMD_IS_APU)
  		return igp_read_bios_from_vram(adev);
  	else
-		return amdgpu_asic_read_disabled_bios(adev);
+		return (!adev->asic_funcs || !adev->asic_funcs->read_disabled_bios) ?
+			false : amdgpu_asic_read_disabled_bios(adev);
  }
 
  #ifdef CONFIG_ACPI

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