From: lirongqing <lirongqing@baidu.com>
To: Sumit Semwal <sumit.semwal@linaro.org>,
Christian König <christian.koenig@amd.com>,
<linux-media@vger.kernel.org>, <dri-devel@lists.freedesktop.org>,
<linaro-mm-sig@lists.linaro.org>, <linux-kernel@vger.kernel.org>
Cc: Li RongQing <lirongqing@baidu.com>
Subject: [PATCH] dma-buf: Move dma_resv_assert_held() after input validation
Date: Wed, 27 May 2026 06:44:49 -0400 [thread overview]
Message-ID: <20260527104449.2350-1-lirongqing@baidu.com> (raw)
From: Li RongQing <lirongqing@baidu.com>
Move dma_resv_assert_held() after the validation of 'attach' and
'attach->dmabuf' to avoid a potential null pointer dereference if
the function is ever called with invalid arguments.
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
drivers/dma-buf/dma-buf-mapping.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dma-buf/dma-buf-mapping.c b/drivers/dma-buf/dma-buf-mapping.c
index 794acff..e6ecd6c 100644
--- a/drivers/dma-buf/dma-buf-mapping.c
+++ b/drivers/dma-buf/dma-buf-mapping.c
@@ -102,12 +102,12 @@ struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach,
size_t i;
int ret;
- dma_resv_assert_held(attach->dmabuf->resv);
-
if (WARN_ON(!attach || !attach->dmabuf || !provider))
/* This function is supposed to work on MMIO memory only */
return ERR_PTR(-EINVAL);
+ dma_resv_assert_held(attach->dmabuf->resv);
+
dma = kzalloc_obj(*dma);
if (!dma)
return ERR_PTR(-ENOMEM);
--
2.9.4
next reply other threads:[~2026-05-27 10:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-27 10:44 lirongqing [this message]
2026-05-28 2:25 ` Claude review: dma-buf: Move dma_resv_assert_held() after input validation Claude Code Review Bot
2026-05-28 2:25 ` Claude Code Review Bot
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=20260527104449.2350-1-lirongqing@baidu.com \
--to=lirongqing@baidu.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=sumit.semwal@linaro.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