diff options
author | Philipp Zabel <p.zabel@pengutronix.de> | 2017-09-13 16:08:19 +0200 |
---|---|---|
committer | Eric Engestrom <eric.engestrom@imgtec.com> | 2017-09-14 10:36:07 +0100 |
commit | 6dca9387d20204898f9e831d59b725d062513fd0 (patch) | |
tree | 66b71c451686200ca66181ca993c901dfe313fb1 /etnaviv/etnaviv_bo.c | |
parent | d55d0804f9e37637d7510f38f97e07a50c6b7baa (diff) |
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 ceb70a6b1015 ("freedreno: prevent deadlock in error path").
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Diffstat (limited to 'etnaviv/etnaviv_bo.c')
-rw-r--r-- | etnaviv/etnaviv_bo.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/etnaviv/etnaviv_bo.c b/etnaviv/etnaviv_bo.c index 4fe877f1..78b9cd27 100644 --- a/etnaviv/etnaviv_bo.c +++ b/etnaviv/etnaviv_bo.c @@ -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; } |