va: allocator: Fix possible memory leaks
authorMengkejiergeli Ba <mengkejiergeli.ba@intel.com>
Tue, 12 Oct 2021 09:32:30 +0000 (17:32 +0800)
committerMengkejiergeli Ba <mengkejiergeli.ba@intel.com>
Mon, 25 Oct 2021 07:03:30 +0000 (15:03 +0800)
commit164244a2ebdfb21a704df27c5dbede5c9435a300
tree1ce885d3bc3dfc12bf92bea9a6f768a46ec0424b
parent8e3f8e6f7d351c358d45e3ac9cf7c59e4825cc94
va: allocator: Fix possible memory leaks

At gst_va_dmabuf_allocator_setup_buffer_full, static code analysis tool
does not know number of objects in descriptor is always larger than 0 if
export_surface_to_dmabuf succeeds. Thus, the tool will assume buf is
allocated with mem but not released when desc.num_objects equals to 0
and raise a mem leak issue.

For gst_va_dambuf_memories_setup, we should also inform the tool that
n_planes will be larger than 0 by checking the value at very beginning.
Then, the defect similar to above will not be raised during static analysis.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1241>
subprojects/gst-plugins-bad/sys/va/gstvaallocator.c