Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/vmwgfx: Fix src/dst_pitch confusion

The src/dst_pitch got mixed up during the rework of the function, make
sure the offset's refer to the correct one.

Spotted by clang:
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;
^
= 0
1 error generated.

Signed-off-by: Zack Rusin <zackr@vmware.com>
Reported-by: Nathan Chancellor <nathan@kernel.org>
Reported-by: Dave Airlie <airlied@gmail.com>
Link: https://github.com/ClangBuiltLinux/linux/issues/1811
Fixes: 39985eea5a6d ("drm/vmwgfx: Abstract placement selection")
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Martin Krastev <krastevm@vmware.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20230314211445.1363828-1-zack@kde.org

+2 -2
+2 -2
drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
··· 506 506 /* Assume we are blitting from Guest (bo) to Host (display_srf) */ 507 507 src_pitch = stdu->display_srf->metadata.base_size.width * stdu->cpp; 508 508 src_bo = &stdu->display_srf->res.guest_memory_bo->tbo; 509 - src_offset = ddirty->top * dst_pitch + ddirty->left * stdu->cpp; 509 + src_offset = ddirty->top * src_pitch + ddirty->left * stdu->cpp; 510 510 511 511 dst_pitch = ddirty->pitch; 512 512 dst_bo = &ddirty->buf->tbo; 513 - dst_offset = ddirty->fb_top * src_pitch + ddirty->fb_left * stdu->cpp; 513 + dst_offset = ddirty->fb_top * dst_pitch + ddirty->fb_left * stdu->cpp; 514 514 515 515 (void) vmw_bo_cpu_blit(dst_bo, dst_offset, dst_pitch, 516 516 src_bo, src_offset, src_pitch,