[PATCH] drm: cast calculation to __u64 in qxl_mode_dumb_create()

Gax-c zichenxie0106 at gmail.com
Mon Nov 25 17:25:17 UTC 2024


From: Zichen Xie <zichenxie0106 at gmail.com>

Like commit b0b0d811eac6 ("drm/mediatek: Fix coverity issue with
unintentional integer overflow"), directly multiply pitch and
args->height may lead to integer overflow. Add a cast to avoid it.

Signed-off-by: Zichen Xie <zichenxie0106 at gmail.com>
---
 drivers/gpu/drm/qxl/qxl_dumb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/qxl/qxl_dumb.c b/drivers/gpu/drm/qxl/qxl_dumb.c
index 17df5c7ccf69..74076c87a002 100644
--- a/drivers/gpu/drm/qxl/qxl_dumb.c
+++ b/drivers/gpu/drm/qxl/qxl_dumb.c
@@ -41,7 +41,7 @@ int qxl_mode_dumb_create(struct drm_file *file_priv,
 	uint32_t pitch, format;
 
 	pitch = args->width * ((args->bpp + 1) / 8);
-	args->size = pitch * args->height;
+	args->size = (__u64)pitch * args->height;
 	args->size = ALIGN(args->size, PAGE_SIZE);
 
 	switch (args->bpp) {
-- 
2.34.1



More information about the dri-devel mailing list