drm/vmwgfx: Fix uninitialized use of dst_pitch in vmw_stdu_bo_cpu_commit()
Subsystems (3)
PATCH 1/1 drm/vmwgfx: Fix uninitialized use of dst_pitch in vmw_stdu_bo_cpu_commit()
Clang warns (or errors with CONFIG_WERROR):
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c:509:29: error: variable 'dst_pitch' is uninitialized when used here [-Werror,-Wuninitialized]
src_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp;
^~~~~~~~~
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c:492:26: note: initialize the variable 'dst_pitch' to silence this warning
s32 src_pitch, dst_pitch;
^
= 01 error generated.
The assignments were switched around in such a way that dst_pitch was used before it was assigned. Swap the pitch assignments to fix the issue and make it clear which section they are used in.
---
I am not sure if this is the right fix, as it was not entirely clear to me that src_pitch and dst_pitch were being used in the right assignments but this is the obvious fix otherwise. Consider this a bug report if not :)
--- drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +2 -2
@@ -504,11 +504,11 @@ static void vmw_stdu_bo_cpu_commit(struct vmw_kms_dirty *dirty)return ;/* Assume we are blitting from Guest (bo) to Host (display_srf) */ - src_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; + dst_pitch = ddirty->pitch; src_bo = &stdu->display_srf->res.guest_memory_bo->tbo; src_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp; - dst_pitch = ddirty->pitch; + src_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; dst_bo = &ddirty->buf->tbo; dst_offset = ddirty->fb_top * src_pitch + ddirty->fb_left * stdu->cpp;
---
base-commit: c87e859cdeb5d106cb861326e3135c606d61f88d
change-id: 20230314-vmware-wuninitialized-28666fb5a62b
Best regards,
Signature · 1 line
Nathan Chancellor <[email protected]>
Quoted 41 lines · Nathan Chancellor
Clang warns (or errors with
CONFIG_WERROR):
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c:509:29: error: variable 'dst_pitch' is uninitialized when used here [-Werror,-Wuninitialized]
src_offset=ddirty->top*dst_pitch+ddirty->left*stdu->cpp; ^~~~~~~~~drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c:492:26: note: initialize the variable 'dst_pitch' to silence this warning
s32src_pitch,dst_pitch;
^
= 0
1 error generated.The assignments were switched around in such a way that
dst_pitchwas used before it was assigned. Swap the pitch assignments to fix the issue and make it clear which section they are used in.Fixes 39985eea5a6d ("drm/vmwgfx: Abstract placement selection")Signed-off-by Nathan Chancellor <[email protected]>---
I am not sure if this is the right fix, as it was not entirely clear to me thatsrc_pitchanddst_pitchwere being used in the right assignments but this is the obvious fix otherwise. Consider this a bug report if not :)
---
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c | 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c +0
-0@@ -504,11 +504,11 @@ static void vmw_stdu_bo_cpu_commit(struct vmw_kms_dirty *dirty) return;
/* Assume we are blitting from Guest (bo) to Host (display_srf) */ - src_pitch =stdu->display_srf->metadata.base_size.width*stdu->cpp;
Quoted 8 lines
+ dst_pitch =
ddirty->pitch;
src_bo =&stdu->display_srf->res.guest_memory_bo->tbo;src_offset=ddirty->top*dst_pitch+ddirty->left*stdu->cpp;
- dst_pitch =ddirty->pitch;
+ src_pitch =stdu->display_srf->metadata.base_size.width*stdu->cpp;dst_bo=&ddirty->buf->tbo;
dst_offset =ddirty->fb_top*src_pitch+ddirty->fb_left*stdu->cpp;
Thanks Nathan! In this case we just want to switch the usage instead of what those variables are. I'll send a patch out in a second.
z