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
parent
d55d0804f9
commit
6dca9387d2
|
@ -206,10 +206,15 @@ struct etna_bo *etna_bo_from_dmabuf(struct etna_device *dev, int fd)
|
||||||
int ret, size;
|
int ret, size;
|
||||||
uint32_t handle;
|
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);
|
pthread_mutex_lock(&table_lock);
|
||||||
|
|
||||||
ret = drmPrimeFDToHandle(dev->fd, fd, &handle);
|
ret = drmPrimeFDToHandle(dev->fd, fd, &handle);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
|
pthread_mutex_unlock(&table_lock);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue