Skip to contentSkip to conversation

drm/msm/submit: fix overflow check on 64-bit architectures

PATCH In review Arnd Bergmann 2 participants 2 messages Sep 27, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm/submit: fix overflow check on 64-bit architectures

From: Arnd Bergmann <[email protected]>

The overflow check does causes a warning from clang-14 when 'sz' is a type that is smaller than size_t:

drivers/gpu/drm/msm/msm_gem_submit.c:217:10: error: result of comparison of constant 18446744073709551615 with expression of type 'unsigned int' is always false [-Werror,-Wtautological-constant-out-of-range-compare]

                if (sz == SIZE_MAX) {

Change the type accordingly.

Fixes 20224d715a88 ("drm/msm/submit: Move copy_from_user ahead of locking bos")
---
 drivers/gpu/drm/msm/msm_gem_submit.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_gem_submit.c +2 -1
index fdc5367aecaa..ac23bbdb0bab 100644
@@ -171,7 +171,8 @@ static int submit_lookup_objects(struct msm_gem_submit *submit,
 static int submit_lookup_cmds(struct msm_gem_submit *submit,
 		struct drm_msm_gem_submit *args, struct drm_file *file)
 {
-	unsigned i, sz;
+	unsigned i;
+	size_t sz;
 	int ret = 0;
 
 	for (i = 0; i < args->nr_cmds; i++) {
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw

Quoting Arnd Bergmann (2021-09-27 04:36:23)

Quoted 5 lines

From: Arnd Bergmann <[email protected]>

The overflow check does causes a warning from clang-14 when 'sz' is a type that is smaller than size_t:

Quoted 8 lines

drivers/gpu/drm/msm/msm_gem_submit.c:217:10: error: result of comparison of constant 18446744073709551615 with expression of type 'unsigned int' is always false [-Werror,-Wtautological-constant-out-of-range-compare]

                if (sz == SIZE_MAX) {

Change the type accordingly.

Fixes 20224d715a88 ("drm/msm/submit: Move copy_from_user ahead of locking bos")

---