]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
video: tegra: host: Fix pin error paths
authorArto Merilainen <amerilainen@nvidia.com>
Mon, 30 Dec 2013 13:58:08 +0000 (15:58 +0200)
committerTerje Bergstrom <tbergstrom@nvidia.com>
Tue, 31 Dec 2013 09:18:51 +0000 (01:18 -0800)
The code did not release the handle private data mutex correctly if it
failed to pin the handle. This lead to deadlock when we later tried to
pin/unpin the same handle.

Bug 1408131

Change-Id: Ie14abf63f81190fd12c176c74d81af2f96e014b2
Signed-off-by: Arto Merilainen <amerilainen@nvidia.com>
Reviewed-on: http://git-master/r/350631
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
drivers/video/tegra/host/nvmap.c

index fc045201484c71affcce1e49f651d71bfdf04228..8e5a36d5d0497f4d2d017f406265f16b65d394ff 100644 (file)
@@ -176,18 +176,22 @@ priv_exist_or_err:
                        if (IS_ERR(as_priv->sgt)) {
                                sgt = as_priv->sgt;
                                as_priv->sgt = NULL;
+                               mutex_unlock(&priv->lock);
                                return sgt;
                        }
                }
        } else if (as_priv->pin_count == 0) {
                as_priv->attach = dma_buf_attach(dmabuf, dev);
-               if (IS_ERR(as_priv->attach))
+               if (IS_ERR(as_priv->attach)) {
+                       mutex_unlock(&priv->lock);
                        return (struct sg_table *)as_priv->attach;
+               }
 
                as_priv->sgt = dma_buf_map_attachment(as_priv->attach,
                                                      DMA_BIDIRECTIONAL);
                if (IS_ERR(as_priv->sgt)) {
                        dma_buf_detach(dmabuf, as_priv->attach);
+                       mutex_unlock(&priv->lock);
                        return as_priv->sgt;
                }
        }