[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20f049cc-41f4-4b23-b4a7-5d41dca7c7e5@gmail.com>
Date: Tue, 7 Oct 2025 09:07:01 +0100
From: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@...il.com>
To: Thomas Zimmermann <tzimmermann@...e.de>,
maarten.lankhorst@...ux.intel.com, mripard@...nel.org, airlied@...il.com,
simona@...ll.ch, mingo@...nel.org, tglx@...utronix.de, jfalempe@...hat.com,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
linux-kernel-mentees@...ts.linuxfoundation.org, skhan@...uxfoundation.org,
david.hunter.linux@...il.com, rubenru09@....com
Subject: Re: [PATCH v2] drm/gud: Use kmalloc_array() instead of kmalloc()
On 10/7/25 8:45 AM, Thomas Zimmermann wrote:
> Hi
>
> Am 23.09.25 um 10:51 schrieb Mehdi Ben Hadj Khelifa:
>> Replace kmalloc with kmalloc array in drm/gud/gud_pipe.c since the
>> calculation inside kmalloc is dynamic 'width * height' to avoid
>> overflow.
>>
>> Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@...il.com>
>> ---
>> Changelog:
>>
>> Changes since v1:
>> - Use of width as element count and height as size of element to
>> eliminate the mentionned calculation and overflow issues.
>>
>> drivers/gpu/drm/gud/gud_pipe.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/gud/gud_pipe.c b/drivers/gpu/drm/gud/
>> gud_pipe.c
>> index 8d548d08f127..8898dc9393fb 100644
>> --- a/drivers/gpu/drm/gud/gud_pipe.c
>> +++ b/drivers/gpu/drm/gud/gud_pipe.c
>> @@ -70,7 +70,7 @@ static size_t gud_xrgb8888_to_r124(u8 *dst, const
>> struct drm_format_info *format
>> height = drm_rect_height(rect);
>> len = drm_format_info_min_pitch(format, 0, width) * height;
>> - buf = kmalloc(width * height, GFP_KERNEL);
>> + buf = kmalloc_array(width, height, GFP_KERNEL);
>
> One nitpick here: the first parameter is the number of elements and the
> second parameter is the size of an individual element. [1] So the
> arguments 'width' and 'height' should be reversed. Please resubmit.
>
Understood,I will be sending v3 shortly.
> Best regards
> Thomas
>
Best Regards,
Mehdi
> [1] https://elixir.bootlin.com/linux/v6.17.1/source/tools/include/linux/
> slab.h#L15
>
>> if (!buf)
>> return 0;
>
Powered by blists - more mailing lists