Re: [PATCH] efi: fix memory leak in efi_mem_reserve_iomem()

From: Markus Elfring

Date: Sat Dec 05 2026 - 14:21:11 EST


> Hi efi subsystem,
>
> I reading the code of efi.c and, is noted a small memory leak:
>
> In this line:
>
> ret = parent ? request_resource(parent, res) : 0;
>
> If ret == 0, is success. But, if not is 0 (ret != 0) ? This patch added a verification
> to this case, removing res for evits a memory leak and return the ret.

Please refine such a change description.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.4-rc5#n94

How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.4-rc5#n145
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v7.4-rc5#n34


…
+++ b/drivers/firmware/efi/efi.c
…
> @@ -1113,6 +1113,11 @@ static int efi_mem_reserve_iomem(phys_addr_t addr, u64 size)
> parent = request_resource_conflict(&iomem_resource, res);
> ret = parent ? request_resource(parent, res) : 0;
>
> + if (ret) {
…

I suggest to omit a blank line at this source code place.

Regards,
Markus