Skip to content

Commit

Permalink
dma-buf: Make locking consistent in dma_buf_detach()
Browse files Browse the repository at this point in the history
The dma_buf_detach() locks attach->dmabuf->resv and then unlocks
dmabuf->resv, which could be a two different locks from a static
code checker perspective. In particular this triggers Smatch to
report the "double unlock" error. Make the locking pointers consistent.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Link: https://lore.kernel.org/dri-devel/Y1fLfsccW3AS%2Fo+%2F@kili/
Fixes: 809d9c7 ("dma-buf: Move dma_buf_attach() to dynamic locking specification")
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221030154412.8320-2-dmitry.osipenko@collabora.com
  • Loading branch information
Dmitry Osipenko committed Nov 2, 2022
1 parent 3876599 commit d3292da
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/dma-buf/dma-buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -995,10 +995,10 @@ static void __unmap_dma_buf(struct dma_buf_attachment *attach,
*/
void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
{
if (WARN_ON(!dmabuf || !attach))
if (WARN_ON(!dmabuf || !attach || dmabuf != attach->dmabuf))
return;

dma_resv_lock(attach->dmabuf->resv, NULL);
dma_resv_lock(dmabuf->resv, NULL);

if (attach->sgt) {

Expand Down

0 comments on commit d3292da

Please sign in to comment.