From: Zack Rusin <zackr@vmware.com>
To: "nathan@kernel.org" <nathan@kernel.org>
Cc: "patches@lists.linux.dev" <patches@lists.linux.dev>,
Maaz Mombasawala <mombasawalam@vmware.com>,
"tzimmermann@suse.de" <tzimmermann@suse.de>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"llvm@lists.linux.dev" <llvm@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Martin Krastev <krastevm@vmware.com>,
"trix@redhat.com" <trix@redhat.com>,
"ndesaulniers@google.com" <ndesaulniers@google.com>,
Linux-graphics-maintainer <Linux-graphics-maintainer@vmware.com>
Subject: Re: [PATCH] drm/vmwgfx: Fix uninitialized use of dst_pitch in vmw_stdu_bo_cpu_commit()
Date: Tue, 14 Mar 2023 21:13:24 +0000 [thread overview]
Message-ID: <0d916c098eccdb28db352f7fa01cd401895c734f.camel@vmware.com> (raw)
In-Reply-To: <20230314-vmware-wuninitialized-v1-1-1bb4b0989758@kernel.org>
On Tue, 2023-03-14 at 08:38 -0700, Nathan Chancellor wrote:
> 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.
>
> 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.
>
> Fixes: 39985eea5a6d ("drm/vmwgfx: Abstract placement selection")
> Link:
> https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FClangBuiltLinux%2Flinux%2Fissues%2F1811&data=05%7C01%7Czackr%40vmware.com%7C37398ac97246436c2efc08db24a226d5%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C638144051125910171%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=HtZTNLdmCAzHfRoEG6vsWcSul4YRSZ56BO2ZUHnUCj4%3D&reserved=0
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
> 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(-)
>
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
> b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
> index d79a6eccfaa4..030e977c68e2 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_stdu.c
> @@ -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;
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
prev parent reply other threads:[~2023-03-14 21:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-14 15:38 Nathan Chancellor
2023-03-14 21:13 ` Zack Rusin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0d916c098eccdb28db352f7fa01cd401895c734f.camel@vmware.com \
--to=zackr@vmware.com \
--cc=Linux-graphics-maintainer@vmware.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=krastevm@vmware.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mombasawalam@vmware.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=patches@lists.linux.dev \
--cc=trix@redhat.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®