[PATCH 5/5] drm/i915/gvt: Assign NULL to the pointer after memory free.
Colin Xu
Colin.Xu at intel.com
Mon Apr 8 07:33:13 UTC 2019
On 2019-04-08 13:55, Aleksei Gimbitskii wrote:
> The klocwork static code analyzer complains about using pointer after
> being freed, because further we pass it to the gvt_vgpu_err() function.
> Assign pointer to be NULL intentionaly, to meet requirements of the code
> analyzer.
>
> This patch fixed the issue #648 reported as error by klocwork.
>
> Signed-off-by: Aleksei Gimbitskii <aleksei.gimbitskii at intel.com>
> Cc: Zhenyu Wang <zhenyuw at linux.intel.com>
> Cc: Zhi Wang <zhi.a.wang at intel.com>
> ---
> drivers/gpu/drm/i915/gvt/gtt.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c
> index 7dc09b389e59..3cf3984aae41 100644
> --- a/drivers/gpu/drm/i915/gvt/gtt.c
> +++ b/drivers/gpu/drm/i915/gvt/gtt.c
> @@ -1098,6 +1098,7 @@ static struct intel_vgpu_ppgtt_spt *ppgtt_populate_spt_by_guest_entry(
>
> err_free_spt:
> ppgtt_free_spt(spt);
> + spt = NULL;
Logically it's ok to explicit set spt to NULL. However from debug purpose label "err_free_spt"
is jumped to due to failure of intel_vgpu_enable_page_track or ppgtt_populate_spt, not same as
label "err". It's better to make dbgmsg more clear about which spt fails in such case so that
the lifecycle of a spt in dbgmsg is more clear for different situations.
> err:
> gvt_vgpu_err("fail: shadow page %p guest entry 0x%llx type %d\n",
> spt, we->val64, we->type);
--
Best Regards,
Colin Xu
More information about the intel-gvt-dev
mailing list