[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220926092315.17193-1-liqiong@nfschina.com>
Date: Mon, 26 Sep 2022 17:23:15 +0800
From: Li Qiong <liqiong@...china.com>
To: Rob Clark <robdclark@...il.com>,
Abhinav Kumar <quic_abhinavk@...cinc.com>,
Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
Sean Paul <sean@...rly.run>, David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>
Cc: linux-arm-msm@...r.kernel.org, dri-devel@...ts.freedesktop.org,
freedreno@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
Yu Zhe <yuzhe@...china.com>, Li Qiong <liqiong@...china.com>
Subject: [PATCH] drm/msm/gem: Use size_add() against integer overflow
"struct_size() + n" may cause a integer overflow,
use size_add() to handle it.
Signed-off-by: Li Qiong <liqiong@...china.com>
---
drivers/gpu/drm/msm/msm_gem_submit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index c9e4aeb14f4a..3dec87e46e50 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -30,8 +30,8 @@ static struct msm_gem_submit *submit_create(struct drm_device *dev,
uint64_t sz;
int ret;
- sz = struct_size(submit, bos, nr_bos) +
- ((u64)nr_cmds * sizeof(submit->cmd[0]));
+ sz = size_add(struct_size(submit, bos, nr_bos),
+ ((u64)nr_cmds * sizeof(submit->cmd[0])));
if (sz > SIZE_MAX)
return ERR_PTR(-ENOMEM);
--
2.11.0
Powered by blists - more mailing lists