[V2,2/6] drm/i915/gvt: Do not copy the uninitialized pointer from fb_info

Submitted by Aleksei Gimbitskii on April 11, 2019, 10:46 a.m.

Details

Message ID 20190411104631.7627-3-aleksei.gimbitskii@intel.com
State New
Headers show
Series "Fix issues reported by klocwork" ( rev: 1 ) in Intel GVT devel

Not browsing as part of any series.

Commit Message

Aleksei Gimbitskii April 11, 2019, 10:46 a.m.
In the code the memcpy() function copied uninitialized pointer in fb_info
to dmabuf_obj->info. Later the pointer in dmabuf_obj->info will be
initialized. To make the code aligned with requirements of the klocwork
static code analyzer, the uninitialized pointer should be initialized
before memcpy().

v2:
- Initialize fb_info.obj in vgpu_get_plane_info(). (Colin Xu)

This patch fixed the critical issue #632 reported by klockwork.

Signed-off-by: Aleksei Gimbitskii <aleksei.gimbitskii@intel.com>
Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
Cc: Zhi Wang <zhi.a.wang@intel.com>
Cc: Colin Xu <colin.xu@intel.com>
---
 drivers/gpu/drm/i915/gvt/dmabuf.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c b/drivers/gpu/drm/i915/gvt/dmabuf.c
index f6be97119968..82eb39c09a21 100644
--- a/drivers/gpu/drm/i915/gvt/dmabuf.c
+++ b/drivers/gpu/drm/i915/gvt/dmabuf.c
@@ -211,6 +211,8 @@  static int vgpu_get_plane_info(struct drm_device *dev,
 	struct intel_vgpu_cursor_plane_format c;
 	int ret;
 
+	memset(info, 0, sizeof(*info));
+
 	if (plane_id == DRM_PLANE_TYPE_PRIMARY) {
 		ret = intel_vgpu_decode_primary_plane(vgpu, &p);
 		if (ret)

Comments

On 2019-04-11 18:46, Aleksei Gimbitskii wrote:
> In the code the memcpy() function copied uninitialized pointer in fb_info
> to dmabuf_obj->info. Later the pointer in dmabuf_obj->info will be
> initialized. To make the code aligned with requirements of the klocwork
> static code analyzer, the uninitialized pointer should be initialized
> before memcpy().
>
> v2:
> - Initialize fb_info.obj in vgpu_get_plane_info(). (Colin Xu)
>
> This patch fixed the critical issue #632 reported by klockwork.
>
> Signed-off-by: Aleksei Gimbitskii <aleksei.gimbitskii@intel.com>
> Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
> Cc: Zhi Wang <zhi.a.wang@intel.com>
> Cc: Colin Xu <colin.xu@intel.com>
Reviewed-by: Colin Xu <colin.xu@intel.com>

Thanks for the fix!
> ---
>   drivers/gpu/drm/i915/gvt/dmabuf.c | 2 ++
>   1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/gvt/dmabuf.c b/drivers/gpu/drm/i915/gvt/dmabuf.c
> index f6be97119968..82eb39c09a21 100644
> --- a/drivers/gpu/drm/i915/gvt/dmabuf.c
> +++ b/drivers/gpu/drm/i915/gvt/dmabuf.c
> @@ -211,6 +211,8 @@ static int vgpu_get_plane_info(struct drm_device *dev,
>   	struct intel_vgpu_cursor_plane_format c;
>   	int ret;
>   
> +	memset(info, 0, sizeof(*info));
> +
>   	if (plane_id == DRM_PLANE_TYPE_PRIMARY) {
>   		ret = intel_vgpu_decode_primary_plane(vgpu, &p);
>   		if (ret)