etnaviv: prevent deadlock in error path

If drmPrimeFDToHandle fails in etna_bo_from_dmabuf, the function must
not return with the table_lock mutex held. Unlock the mutex in the error
path.

Based on ceb70a6b10 ("freedreno: prevent deadlock in error path").

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
main
Philipp Zabel 2017-09-13 16:08:19 +02:00 committed by Eric Engestrom
parent d55d0804f9
commit 6dca9387d2
1 changed files with 5 additions and 0 deletions

View File

@ -206,10 +206,15 @@ struct etna_bo *etna_bo_from_dmabuf(struct etna_device *dev, int fd)
int ret, size;
uint32_t handle;
/* take the lock before calling drmPrimeFDToHandle to avoid
* racing against etna_bo_del, which might invalidate the
* returned handle.
*/
pthread_mutex_lock(&table_lock);
ret = drmPrimeFDToHandle(dev->fd, fd, &handle);
if (ret) {
pthread_mutex_unlock(&table_lock);
return NULL;
}