[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260119123809.GS830755@noisy.programming.kicks-ass.net>
Date: Mon, 19 Jan 2026 13:38:09 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Weigang He <geoffreyhe2@...il.com>
Cc: Josh Poimboeuf <jpoimboe@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] objtool: Fix memory leak in elf_alloc_reloc() on realloc
failure
On Sun, Jan 18, 2026 at 06:56:43AM +0000, Weigang He wrote:
> When realloc() fails in elf_alloc_reloc(), the original buffer pointer
> is overwritten with NULL before the failure is detected. This causes
> the original buffer to become unreachable, resulting in a memory leak.
>
> Fix this by using a temporary variable to hold the realloc() result.
> If realloc() fails, free the original buffer and set d_buf to NULL to
> maintain the expected error state before returning -1.
>
> This bug is found by my static analysis tool and my code review.
Yeah, except that the moment this error is actually hit, the tool will
exit, freeing all memory.
Powered by blists - more mailing lists