From: Maíra Canal <mcanal@igalia.com>
To: "Alexander A. Klimov" <grandmaster@al2klimov.de>,
Maxime Ripard <mripard@kernel.org>,
Dave Stevenson <dave.stevenson@raspberrypi.com>,
Raspberry Pi Kernel Maintenance <kernel-list@raspberrypi.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
Eric Anholt <eric@anholt.net>,
"open list:DRM DRIVERS" <dri-devel@lists.freedesktop.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/vc4: fix krealloc() memory leak
Date: Thu, 28 May 2026 16:01:32 -0300 [thread overview]
Message-ID: <e486203f-dcc4-456f-af36-45ef8e3349f6@igalia.com> (raw)
In-Reply-To: <5642dd71-01ad-4db2-b0b8-5431298b39a1@al2klimov.de>
Hi Alexander,
On 28/05/26 15:54, Alexander A. Klimov wrote:
>
>
> On 5/28/26 20:17, Maíra Canal wrote:
>> Hi Alexander,
>>
>> LGTM, but a small styling nit:
>>
>> On 26/05/26 15:41, Alexander A. Klimov wrote:
>>> Don't just overwrite the original pointer passed to krealloc()
>>> with its return value without checking latter:
>>>
>>> MEM = krealloc(MEM, SZ, GFP);
>>>
>>> If krealloc() returns NULL, that erases the pointer
>>> to the still allocated memory, hence leaks this memory.
>>> Instead, use a temporary variable, check it's not NULL
>>> and only then assign it to the original pointer:
>>>
>>> TMP = krealloc(MEM, SZ, GFP);
>>> if (!TMP) return;
>>> MEM = TMP;
>>>
>>> Fixes: 6d45c81d229d ("drm/vc4: Add support for branching in shader
>>> validation.")
>>> Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
>>> ---
>>> drivers/gpu/drm/vc4/vc4_validate_shaders.c | 12 ++++++------
>>> 1 file changed, 6 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/vc4/vc4_validate_shaders.c b/drivers/
>>> gpu/drm/vc4/vc4_validate_shaders.c
>>> index d48cf76983c0..af48758592f9 100644
>>> --- a/drivers/gpu/drm/vc4/vc4_validate_shaders.c
>>> +++ b/drivers/gpu/drm/vc4/vc4_validate_shaders.c
>>> @@ -291,14 +291,14 @@ static bool
>>> require_uniform_address_uniform(struct vc4_validated_shader_info *va
>>> uint32_t o = validated_shader->num_uniform_addr_offsets;
>>> uint32_t num_uniforms = validated_shader->uniforms_size / 4;
>>
>> Declare the variable here.
>
> Strange...
> It comes already directly after num_uniforms, doesn't it?
Yeah, it does. However, usually, we declare the variables and then we
proceed to the functions. Check, for example, the function
record_texture_sample() in vc4.
Best regards,
- Maíra
> At least when I apply my patch to Linus' master.
next prev parent reply other threads:[~2026-05-28 19:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260526184105.18962-1-grandmaster@al2klimov.de>
2026-05-26 18:41 ` [PATCH] drm/vc4: fix krealloc() memory leak Alexander A. Klimov
2026-05-27 4:21 ` Claude review: " Claude Code Review Bot
2026-05-27 4:21 ` Claude Code Review Bot
2026-05-28 18:17 ` [PATCH] " Maíra Canal
2026-05-28 18:54 ` Alexander A. Klimov
2026-05-28 19:01 ` Maíra Canal [this message]
2026-05-31 19:55 ` [PATCH v2] " Alexander A. Klimov
2026-06-01 3:34 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e486203f-dcc4-456f-af36-45ef8e3349f6@igalia.com \
--to=mcanal@igalia.com \
--cc=airlied@gmail.com \
--cc=dave.stevenson@raspberrypi.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=eric@anholt.net \
--cc=grandmaster@al2klimov.de \
--cc=kernel-list@raspberrypi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox