[PATCH v3 5/6] drm/i915/gvt: Assign NULL to the pointer after memory free.

Zhenyu Wang zhenyuw at linux.intel.com
Thu Apr 25 03:14:06 UTC 2019


On 2019.04.23 15:04:12 +0300, 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 061499a38f4d..927753a59a1e 100644
> --- a/drivers/gpu/drm/i915/gvt/gtt.c
> +++ b/drivers/gpu/drm/i915/gvt/gtt.c
> @@ -1106,6 +1106,7 @@ static struct intel_vgpu_ppgtt_spt *ppgtt_populate_spt_by_guest_entry(
>  
>  err_free_spt:
>  	ppgtt_free_spt(spt);
> +	spt = NULL;
>  err:
>  	gvt_vgpu_err("fail: shadow page %p guest entry 0x%llx type %d\n",
>  		     spt, we->val64, we->type);

I think we can remove this error message which doesn't tell the reason
to fail at all, but have err message in earlier path where we can
indicate the reason.

-- 
Open Source Technology Center, Intel ltd.

$gpg --keyserver wwwkeys.pgp.net --recv-keys 4D781827
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/intel-gvt-dev/attachments/20190425/25b05d56/attachment-0001.sig>


More information about the intel-gvt-dev mailing list