Skip to content

Commit 01352cf

Browse files
Yuuoniygregkh
authored andcommitted
ACPI/IORT: Fix memory leak in iort_rmr_alloc_sids()
commit f3ef711 upstream. If krealloc_array() fails in iort_rmr_alloc_sids(), the function returns NULL but does not free the original 'sids' allocation. This results in a memory leak since the caller overwrites the original pointer with the NULL return value. Fixes: 491cf4a ("ACPI/IORT: Add support to retrieve IORT RMR reserved regions") Cc: <stable@vger.kernel.org> # 6.0.x Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Reviewed-by: Hanjun Guo <guohanjun@huawei.com> Link: https://lore.kernel.org/r/20250828112243.61460-1-linmq006@gmail.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 565d2c1 commit 01352cf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/acpi/arm64/iort.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,10 @@ static u32 *iort_rmr_alloc_sids(u32 *sids, u32 count, u32 id_start,
937937

938938
new_sids = krealloc_array(sids, count + new_count,
939939
sizeof(*new_sids), GFP_KERNEL);
940-
if (!new_sids)
940+
if (!new_sids) {
941+
kfree(sids);
941942
return NULL;
943+
}
942944

943945
for (i = count; i < total_count; i++)
944946
new_sids[i] = id_start++;

0 commit comments

Comments
 (0)