From: Laurent Pinchart Date: Thu, 26 Jan 2012 11:27:25 +0000 (+0100) Subject: dma-buf: Move code out of mutex-protected section in dma_buf_attach() X-Git-Tag: Ubuntu-goldfish-3.4.0-4.27~607^2~8 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=2ed9201bdd9a8e462d768a838fb2bc944c6887a4;p=mirror_ubuntu-zesty-kernel.git dma-buf: Move code out of mutex-protected section in dma_buf_attach() Some fields can be set without mutex protection. Initialize them before locking the mutex. Signed-off-by: Laurent Pinchart Reviewed-by: Daniel Vetter Signed-off-by: Sumit Semwal --- diff --git a/drivers/base/dma-buf.c b/drivers/base/dma-buf.c index 97450a52172c..8afe2dd17912 100644 --- a/drivers/base/dma-buf.c +++ b/drivers/base/dma-buf.c @@ -192,10 +192,11 @@ struct dma_buf_attachment *dma_buf_attach(struct dma_buf *dmabuf, if (attach == NULL) return ERR_PTR(-ENOMEM); - mutex_lock(&dmabuf->lock); - attach->dev = dev; attach->dmabuf = dmabuf; + + mutex_lock(&dmabuf->lock); + if (dmabuf->ops->attach) { ret = dmabuf->ops->attach(dmabuf, dev, attach); if (ret)