[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <m2i5ewrkh72dl3lcrfqpoy7l3ohjkraogpqkskvvybg2oshvm6@dnximnav2uqf>
Date: Thu, 3 Jul 2025 21:55:53 -0700
From: Dmitry Torokhov <dmitry.torokhov@...il.com>
To: Yunshui Jiang <jiangyunshui@...inos.cn>
Cc: linux-kernel@...r.kernel.org, linux-input@...r.kernel.org
Subject: Re: [PATCH] Input: cs40l50: Fix potential NULL dereference and
memory leak
Hi Yunshui,
On Fri, Jul 04, 2025 at 10:40:10AM +0800, Yunshui Jiang wrote:
> The cs40l50_upload_owt() function allocates memory via kmalloc()
> without checking for allocation failure, which could lead to a
> NULL pointer dereference when GFP_KERNEL allocation fails under
> memory pressure.
Yes, the check is indeed missing. It is likely that the allocation is
small enough so it always succeeds (or waits indefinitely), but it is a
good idea to add the check nevertheless.
>
> Additionally, if any subsequent operation fails after successful
> allocation, the allocated memory is not freed, causing a memory
> leak.
This is not correct. Because the new_owt_effect_data variable is
annotated as __free(kfree) it will be automatically freed at the end of
the function scope. Your patch introduces a double-free.
I will adjust to only keep the check and apply, thank you.
Thanks.
--
Dmitry
Powered by blists - more mailing lists