From: Dan Carpenter <dan.carpenter@oracle.com>
To: dmitry.osipenko@collabora.com
Cc: dri-devel@lists.freedesktop.org
Subject: [bug report] dma-buf: Move dma_buf_attach() to dynamic locking specification
Date: Tue, 25 Oct 2022 14:41:50 +0300 [thread overview]
Message-ID: <Y1fLfsccW3AS/o+/@kili> (raw)
Hello Dmitry Osipenko,
The patch 809d9c72c2f8: "dma-buf: Move dma_buf_attach() to dynamic
locking specification" from Oct 17, 2022, leads to the following
Smatch static checker warning:
drivers/dma-buf/dma-buf.c:957 dma_buf_dynamic_attach()
error: double unlocked 'dmabuf->resv' (orig line 915)
drivers/dma-buf/dma-buf.c
987 /**
988 * dma_buf_detach - Remove the given attachment from dmabuf's attachments list
989 * @dmabuf: [in] buffer to detach from.
990 * @attach: [in] attachment to be detached; is free'd after this call.
991 *
992 * Clean up a device attachment obtained by calling dma_buf_attach().
993 *
994 * Optionally this calls &dma_buf_ops.detach for device-specific detach.
995 */
996 void dma_buf_detach(struct dma_buf *dmabuf, struct dma_buf_attachment *attach)
997 {
998 if (WARN_ON(!dmabuf || !attach))
999 return;
1000
1001 dma_resv_lock(attach->dmabuf->resv, NULL);
In the original code used to take this both the "attach->dmabuf->resv"
and "dmabuf->resv" locks and unlock them both. But now it takes one
lock and unlocks the other. Seems sus.
1002
1003 if (attach->sgt) {
1004
1005 __unmap_dma_buf(attach, attach->sgt, attach->dir);
1006
1007 if (dma_buf_is_dynamic(attach->dmabuf))
1008 dmabuf->ops->unpin(attach);
1009 }
1010 list_del(&attach->node);
1011
1012 dma_resv_unlock(dmabuf->resv);
1013
1014 if (dmabuf->ops->detach)
1015 dmabuf->ops->detach(dmabuf, attach);
1016
1017 kfree(attach);
1018 }
regards,
dan carpenter
next reply other threads:[~2022-10-25 11:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-25 11:41 Dan Carpenter [this message]
2022-10-25 11:54 ` [bug report] dma-buf: Move dma_buf_attach() to dynamic locking specification Dmitry Osipenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y1fLfsccW3AS/o+/@kili \
--to=dan.carpenter@oracle.com \
--cc=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).