drm/radeon: Add the missed acpi_put_table() to fix memory leak
[ Upstream commit 10276a20be1115e1f76c189330da2992df980eee ]
When the radeon driver reads the bios information from ACPI
table in radeon_acpi_vfct_bios(), it misses to call acpi_put_table()
to release the ACPI memory after the init, so add acpi_put_table()
properly to fix the memory leak.
v2: fix text formatting (Alex)
Fixes: 268ba0a99f
("drm/radeon: implement ACPI VFCT vbios fetch (v3)")
Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
832d0e19ce
commit
a0f26560be
@ -612,13 +612,14 @@ static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
|
|||||||
acpi_size tbl_size;
|
acpi_size tbl_size;
|
||||||
UEFI_ACPI_VFCT *vfct;
|
UEFI_ACPI_VFCT *vfct;
|
||||||
unsigned offset;
|
unsigned offset;
|
||||||
|
bool r = false;
|
||||||
|
|
||||||
if (!ACPI_SUCCESS(acpi_get_table("VFCT", 1, &hdr)))
|
if (!ACPI_SUCCESS(acpi_get_table("VFCT", 1, &hdr)))
|
||||||
return false;
|
return false;
|
||||||
tbl_size = hdr->length;
|
tbl_size = hdr->length;
|
||||||
if (tbl_size < sizeof(UEFI_ACPI_VFCT)) {
|
if (tbl_size < sizeof(UEFI_ACPI_VFCT)) {
|
||||||
DRM_ERROR("ACPI VFCT table present but broken (too short #1)\n");
|
DRM_ERROR("ACPI VFCT table present but broken (too short #1)\n");
|
||||||
return false;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
vfct = (UEFI_ACPI_VFCT *)hdr;
|
vfct = (UEFI_ACPI_VFCT *)hdr;
|
||||||
@ -631,13 +632,13 @@ static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
|
|||||||
offset += sizeof(VFCT_IMAGE_HEADER);
|
offset += sizeof(VFCT_IMAGE_HEADER);
|
||||||
if (offset > tbl_size) {
|
if (offset > tbl_size) {
|
||||||
DRM_ERROR("ACPI VFCT image header truncated\n");
|
DRM_ERROR("ACPI VFCT image header truncated\n");
|
||||||
return false;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset += vhdr->ImageLength;
|
offset += vhdr->ImageLength;
|
||||||
if (offset > tbl_size) {
|
if (offset > tbl_size) {
|
||||||
DRM_ERROR("ACPI VFCT image truncated\n");
|
DRM_ERROR("ACPI VFCT image truncated\n");
|
||||||
return false;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (vhdr->ImageLength &&
|
if (vhdr->ImageLength &&
|
||||||
@ -649,15 +650,18 @@ static bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
|
|||||||
rdev->bios = kmemdup(&vbios->VbiosContent,
|
rdev->bios = kmemdup(&vbios->VbiosContent,
|
||||||
vhdr->ImageLength,
|
vhdr->ImageLength,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
|
if (rdev->bios)
|
||||||
|
r = true;
|
||||||
|
|
||||||
if (!rdev->bios)
|
goto out;
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DRM_ERROR("ACPI VFCT table present but broken (too short #2)\n");
|
DRM_ERROR("ACPI VFCT table present but broken (too short #2)\n");
|
||||||
return false;
|
|
||||||
|
out:
|
||||||
|
acpi_put_table(hdr);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
static inline bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
|
static inline bool radeon_acpi_vfct_bios(struct radeon_device *rdev)
|
||||||
|
Loading…
Reference in New Issue
Block a user