From: Ruben Wauters <rubenru09@aol.com>
To: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com>,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
mingo@kernel.org, tglx@linutronix.de, jfalempe@redhat.com,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linuxfoundation.org,
skhan@linuxfoundation.org, david.hunter.linux@gmail.com
Subject: Re: [PATCH v2] drm/gud: Use kmalloc_array() instead of kmalloc()
Date: Sat, 04 Oct 2025 17:13:33 +0100 [thread overview]
Message-ID: <d957bb721c9039287833ca0a9e2cebd60943c5f8.camel@aol.com> (raw)
In-Reply-To: <20250923085144.22582-1-mehdi.benhadjkhelifa@gmail.com>
On Tue, 2025-09-23 at 09:51 +0100, Mehdi Ben Hadj Khelifa wrote:
> 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@gmail.com>
Acked-by: Ruben Wauters <rubenru09@aol.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);
> if (!buf)
> return 0;
>
next prev parent reply other threads:[~2025-10-04 16:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-23 8:51 [PATCH v2] drm/gud: Use kmalloc_array() instead of kmalloc() Mehdi Ben Hadj Khelifa
2025-10-04 16:13 ` Ruben Wauters [this message]
2025-10-07 7:45 ` Thomas Zimmermann
2025-10-07 8:07 ` Mehdi Ben Hadj Khelifa
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=d957bb721c9039287833ca0a9e2cebd60943c5f8.camel@aol.com \
--to=rubenru09@aol.com \
--cc=airlied@gmail.com \
--cc=david.hunter.linux@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=jfalempe@redhat.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mehdi.benhadjkhelifa@gmail.com \
--cc=mingo@kernel.org \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=skhan@linuxfoundation.org \
--cc=tglx@linutronix.de \
--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