VBT not read from opregion needs to be freed. Vbt read from opregion is simply remapped and hence need to point to NULL. While at it assign the type to NONE VBT type. Free the vbt in other cases.
Signed-off-by: Radhakrishna Sripada <radhakrishna.srip...@intel.com> --- drivers/gpu/drm/i915/display/intel_bios.c | 20 +++++++++++++++++-- drivers/gpu/drm/i915/display/intel_opregion.c | 4 ---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_bios.c b/drivers/gpu/drm/i915/display/intel_bios.c index bd46a14a04f5..ccfc4a4e4c98 100644 --- a/drivers/gpu/drm/i915/display/intel_bios.c +++ b/drivers/gpu/drm/i915/display/intel_bios.c @@ -3219,8 +3219,24 @@ void intel_bios_driver_remove(struct drm_i915_private *i915) kfree(entry); } - /* FIXME: Handle vbt free in opregion case. */ - kfree(vbt->vbt); + switch (vbt->type) { + case I915_VBT_SPI: + case I915_VBT_OPROM: + kfree(vbt->vbt); + vbt->type = I915_VBT_NONE; + break; + case I915_VBT_FIRMWARE: + kfree(vbt->vbt_firmware); + fallthrough; + case I915_VBT_OPREGION: + vbt->vbt = NULL; + vbt->type = I915_VBT_NONE; + break; + case I915_VBT_NONE: + break; + default: + MISSING_CASE(vbt->type); + } } void intel_bios_fini_panel(struct intel_panel *panel) diff --git a/drivers/gpu/drm/i915/display/intel_opregion.c b/drivers/gpu/drm/i915/display/intel_opregion.c index 5c4a5ddba01d..b879e89d0fb6 100644 --- a/drivers/gpu/drm/i915/display/intel_opregion.c +++ b/drivers/gpu/drm/i915/display/intel_opregion.c @@ -1257,7 +1257,6 @@ void intel_opregion_unregister(struct drm_i915_private *i915) void intel_opregion_cleanup(struct drm_i915_private *i915) { struct intel_opregion *opregion = &i915->display.opregion; - struct intel_vbt *vbt = &i915->display.vbt; if (!opregion->header) return; @@ -1268,14 +1267,11 @@ void intel_opregion_cleanup(struct drm_i915_private *i915) memunmap(opregion->rvda); opregion->rvda = NULL; } - kfree(vbt->vbt_firmware); - vbt->vbt_firmware = NULL; opregion->header = NULL; opregion->acpi = NULL; opregion->swsci = NULL; opregion->asle = NULL; opregion->asle_ext = NULL; opregion->asls = 0; - vbt->vbt = NULL; opregion->lid_state = NULL; } -- 2.34.1