diff options
author | Chia-I Wu <[email protected]> | 2019-05-15 15:38:49 -0700 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2019-06-12 18:20:30 -0700 |
commit | 900a80f9e4fd3e080c3d048eae8c6e113e9326ba (patch) | |
tree | 71217d6b1add702214d3d409bc93ae2423bd074b /src/gallium/drivers/virgl/virgl_resource.c | |
parent | 74051efbea8f330fcd4b23bfe4d1ccf0c66d0e7e (diff) |
virgl: virgl_transfer should own its virgl_resource
We should avoid having potentially dangling pointers to
pipe_resources in general.
Signed-off-by: Chia-I Wu <[email protected]>
Reviewed-by: Alexandros Frantzis <[email protected]>
Diffstat (limited to 'src/gallium/drivers/virgl/virgl_resource.c')
-rw-r--r-- | src/gallium/drivers/virgl/virgl_resource.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/gallium/drivers/virgl/virgl_resource.c b/src/gallium/drivers/virgl/virgl_resource.c index e840caa52a9..4d427894dac 100644 --- a/src/gallium/drivers/virgl/virgl_resource.c +++ b/src/gallium/drivers/virgl/virgl_resource.c @@ -415,7 +415,9 @@ virgl_resource_create_transfer(struct virgl_context *vctx, if (!trans) return NULL; - trans->base.resource = pres; + /* note that trans is not zero-initialized */ + trans->base.resource = NULL; + pipe_resource_reference(&trans->base.resource, pres); trans->base.level = level; trans->base.usage = usage; trans->base.box = *box; @@ -442,7 +444,9 @@ void virgl_resource_destroy_transfer(struct virgl_context *vctx, struct virgl_transfer *trans) { pipe_resource_reference(&trans->copy_src_res, NULL); + util_range_destroy(&trans->range); + pipe_resource_reference(&trans->base.resource, NULL); slab_free(&vctx->transfer_pool, trans); } |