[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250923110025.1358920-1-rk0006818@gmail.com>
Date: Tue, 23 Sep 2025 16:30:25 +0530
From: Rahul Kumar <rk0006818@...il.com>
To: lanzano.alex@...il.com,
maarten.lankhorst@...ux.intel.com,
mripard@...nel.org,
tzimmermann@...e.de,
airlied@...il.com,
simona@...ll.ch
Cc: dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org,
linux-kernel-mentees@...ts.linuxfoundation.org,
skhan@...uxfoundation.org,
rk0006818@...il.com
Subject: [PATCH] drm/tiny: Use kmalloc_array() instead of kmalloc()
Documentation/process/deprecated.rst recommends against the use of
kmalloc with dynamic size calculations due to the risk of overflow and
smaller allocation being made than the caller was expecting.
Replace kmalloc() with kmalloc_array() in drivers/gpu/drm/tiny/repaper.c
to make the intended allocation size clearer and avoid potential overflow
issues.
Signed-off-by: Rahul Kumar <rk0006818@...il.com>
---
drivers/gpu/drm/tiny/repaper.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/tiny/repaper.c b/drivers/gpu/drm/tiny/repaper.c
index 5c3b51eb0a97..4d439a2d973a 100644
--- a/drivers/gpu/drm/tiny/repaper.c
+++ b/drivers/gpu/drm/tiny/repaper.c
@@ -535,7 +535,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb,
DRM_DEBUG("Flushing [FB:%d] st=%ums\n", fb->base.id,
epd->factored_stage_time);
- buf = kmalloc(fb->width * fb->height / 8, GFP_KERNEL);
+ buf = kmalloc_array(fb->width, fb->height / 8, GFP_KERNEL);
if (!buf) {
ret = -ENOMEM;
goto out_exit;
--
2.43.0
Powered by blists - more mailing lists