* [PATCH] drm/msm: remove some dead code
@ 2026-01-08 19:57 Dan Carpenter
2026-01-08 20:26 ` Dmitry Baryshkov
2026-01-15 21:05 ` Dmitry Baryshkov
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2026-01-08 19:57 UTC (permalink / raw)
To: Rob Clark
Cc: Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm,
dri-devel, freedreno, linux-kernel, kernel-janitors
This is supposed to test for integer overflow but it is wrong and
unnecessary. The size_add()/mul() macros return SIZE_MAX when there is
an integer overflow. This code saves the SIZE_MAX to a u64 and then
tests if the result is greater than SIZE_MAX which it never will be.
Fortunately, when we try to allocate SIZE_MAX bytes the allocation
will fail. We even pass __GFP_NOWARN so the allocation fails
harmlessly and quietly.
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/gpu/drm/msm/msm_gem_vma.c | 8 +-------
1 file changed, 1 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c
index 71d5238437eb..7968c2dccff0 100644
--- a/drivers/gpu/drm/msm/msm_gem_vma.c
+++ b/drivers/gpu/drm/msm/msm_gem_vma.c
@@ -947,15 +947,9 @@ vm_bind_job_create(struct drm_device *dev, struct drm_file *file,
struct msm_gpu_submitqueue *queue, uint32_t nr_ops)
{
struct msm_vm_bind_job *job;
- uint64_t sz;
int ret;
- sz = struct_size(job, ops, nr_ops);
-
- if (sz > SIZE_MAX)
- return ERR_PTR(-ENOMEM);
-
- job = kzalloc(sz, GFP_KERNEL | __GFP_NOWARN);
+ job = kzalloc(struct_size(job, ops, nr_ops), GFP_KERNEL | __GFP_NOWARN);
if (!job)
return ERR_PTR(-ENOMEM);
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/msm: remove some dead code
2026-01-08 19:57 [PATCH] drm/msm: remove some dead code Dan Carpenter
@ 2026-01-08 20:26 ` Dmitry Baryshkov
2026-01-15 21:05 ` Dmitry Baryshkov
1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2026-01-08 20:26 UTC (permalink / raw)
To: Dan Carpenter
Cc: Rob Clark, Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang,
Sean Paul, Marijn Suijten, David Airlie, Simona Vetter,
linux-arm-msm, dri-devel, freedreno, linux-kernel,
kernel-janitors
On Thu, Jan 08, 2026 at 10:57:22PM +0300, Dan Carpenter wrote:
> This is supposed to test for integer overflow but it is wrong and
> unnecessary. The size_add()/mul() macros return SIZE_MAX when there is
> an integer overflow. This code saves the SIZE_MAX to a u64 and then
> tests if the result is greater than SIZE_MAX which it never will be.
> Fortunately, when we try to allocate SIZE_MAX bytes the allocation
> will fail. We even pass __GFP_NOWARN so the allocation fails
> harmlessly and quietly.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/gpu/drm/msm/msm_gem_vma.c | 8 +-------
> 1 file changed, 1 insertions(+), 7 deletions(-)
Fixes: 2e6a8a1fe2b2 ("drm/msm: Add VM_BIND ioctl")
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/msm: remove some dead code
2026-01-08 19:57 [PATCH] drm/msm: remove some dead code Dan Carpenter
2026-01-08 20:26 ` Dmitry Baryshkov
@ 2026-01-15 21:05 ` Dmitry Baryshkov
1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2026-01-15 21:05 UTC (permalink / raw)
To: Rob Clark, Dan Carpenter
Cc: Dmitry Baryshkov, Abhinav Kumar, Jessica Zhang, Sean Paul,
Marijn Suijten, David Airlie, Simona Vetter, linux-arm-msm,
dri-devel, freedreno, linux-kernel, kernel-janitors
On Thu, 08 Jan 2026 22:57:22 +0300, Dan Carpenter wrote:
> This is supposed to test for integer overflow but it is wrong and
> unnecessary. The size_add()/mul() macros return SIZE_MAX when there is
> an integer overflow. This code saves the SIZE_MAX to a u64 and then
> tests if the result is greater than SIZE_MAX which it never will be.
> Fortunately, when we try to allocate SIZE_MAX bytes the allocation
> will fail. We even pass __GFP_NOWARN so the allocation fails
> harmlessly and quietly.
>
> [...]
Applied to msm-next, thanks!
[1/1] drm/msm: remove some dead code
https://gitlab.freedesktop.org/lumag/msm/-/commit/37d2e108de4d
Best regards,
--
With best wishes
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-15 21:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-08 19:57 [PATCH] drm/msm: remove some dead code Dan Carpenter
2026-01-08 20:26 ` Dmitry Baryshkov
2026-01-15 21:05 ` Dmitry Baryshkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox