Skip to content

Commit d3292da

Browse files
committed
dma-buf: Make locking consistent in dma_buf_detach()
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 <[email protected]> Reviewed-by: Christian König <[email protected]> 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 <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 3876599 commit d3292da

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/dma-buf/dma-buf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,10 +995,10 @@ static void __unmap_dma_buf(struct dma_buf_attachment *attach,
995995
*/
996996
void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
997997
{
998-
if (WARN_ON(!dmabuf || !attach))
998+
if (WARN_ON(!dmabuf || !attach || dmabuf != attach->dmabuf))
999999
return;
10001000

1001-
dma_resv_lock(attach->dmabuf->resv, NULL);
1001+
dma_resv_lock(dmabuf->resv, NULL);
10021002

10031003
if (attach->sgt) {
10041004

0 commit comments

Comments
 (0)