minigbm: gralloc0: Fix error handling in lock_ycbcr

cros_gralloc_lock_ycbcr() obtains the mapping first and then fills in
the android_ycbcr struct. However the last step can fail if the backing
format is not included in the switch statement. In this case the function
returns without releasing the mapping.

Fix it by calling mod->drv->unlock() before returning, when the format
is unsupported. Also do not attempt to fill in the struct if the earlier
mod->drv->lock(() fails.

BUG=b:32077885
TEST=lock_ycbcr() fails properly for HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED
 when it is backed by a RGBX_8888 buffer on Poppy.

Change-Id: I0b8cf91c578595a1b6ddc6e21009a8a84b8ac4de
Reviewed-on: https://chromium-review.googlesource.com/544486
Commit-Ready: Tomasz Figa <tfiga@chromium.org>
Tested-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
1 file changed