drivers/dma-buf/dma-buf.c:185:29-39: ERROR: function new_task_dmabuf_record called on line 226 inside lock on line 223 but uses GFP_KERNEL (fwd)
PATCH 6/6 drivers/dma-buf/dma-buf.c:185:29-39: ERROR: function new_task_dmabuf_record called on line 226 inside lock on line 223 but uses GFP_KERNEL (fwd)
---------- Forwarded message ----------
Date: Thu, 10 Jul 2025 00:59:06 +0800
From: kernel test robot <[email protected]>
To: [email protected]
Cc: [email protected], Julia Lawall <[email protected]>
Subject: [android-common:android15-6.6 6/6] drivers/dma-buf/dma-buf.c:185:29-39:
ERROR: function new_task_dmabuf_record called on line 226 inside lock on
line 223 but uses GFP_KERNEL
BCC: [email protected]
CC: [email protected]
TO: [email protected]
tree: https://android.googlesource.com/kernel/common android15-6.6 head: c8fdc081cfa165aaa5bd87979d33b419499574cf commit: f44d593749dcbd4e1013121fa615ecca412d1cb3 [6/6] ANDROID: Track per-process dmabuf RSS
:::::: branch date: 17 hours ago
:::::: commit date: 17 hours ago
config: x86_64-randconfig-r053-20250709 (https://download.01.org/0day-ci/archive/20250710/[email protected]/config)
compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Julia Lawall <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
cocci warnings: (new ones prefixed by >>)
Quoted 1 line
Quoted 1 line
drivers/dma-buf/dma-buf.c:185:29-39: ERROR: function
new_task_dmabuf_recordcalled on line 226 inside lock on line 223 but usesGFP_KERNEL
vim +185 drivers/dma-buf/dma-buf.c
f44d593749dcbd T.J. Mercier 2025-06-25 178
f44d593749dcbd T.J. Mercier 2025-06-25 179 static int new_task_dmabuf_record(struct task_struct *task, struct dma_buf *dmabuf)
f44d593749dcbd T.J. Mercier 2025-06-25 180 {
f44d593749dcbd T.J. Mercier 2025-06-25 181 struct task_dma_buf_record *rec;
f44d593749dcbd T.J. Mercier 2025-06-25 182
f44d593749dcbd T.J. Mercier 2025-06-25 183 lockdep_assert_held(&task->dmabuf_info->lock);
f44d593749dcbd T.J. Mercier 2025-06-25 184
f44d593749dcbd T.J. Mercier 2025-06-25 @185 rec = kmalloc(sizeof(*rec), GFP_KERNEL);
f44d593749dcbd T.J. Mercier 2025-06-25 186 if (!rec)
f44d593749dcbd T.J. Mercier 2025-06-25 187 return -ENOMEM;
f44d593749dcbd T.J. Mercier 2025-06-25 188
f44d593749dcbd T.J. Mercier 2025-06-25 189 task->dmabuf_info->rss += dmabuf->size;
f44d593749dcbd T.J. Mercier 2025-06-25 190 rec->dmabuf = dmabuf;
f44d593749dcbd T.J. Mercier 2025-06-25 191 rec->refcnt = 1;
f44d593749dcbd T.J. Mercier 2025-06-25 192 list_add(&rec->node, &task->dmabuf_info->dmabufs);
f44d593749dcbd T.J. Mercier 2025-06-25 193
f44d593749dcbd T.J. Mercier 2025-06-25 194 return 0;
f44d593749dcbd T.J. Mercier 2025-06-25 195 }
f44d593749dcbd T.J. Mercier 2025-06-25 196
f44d593749dcbd T.J. Mercier 2025-06-25 197 /**
f44d593749dcbd T.J. Mercier 2025-06-25 198 * dma_buf_account_task - Account a dmabuf to a task
f44d593749dcbd T.J. Mercier 2025-06-25 199 * @dmabuf: [in] pointer to dma_buf
f44d593749dcbd T.J. Mercier 2025-06-25 200 * @task: [in] pointer to task_struct
f44d593749dcbd T.J. Mercier 2025-06-25 201 *
f44d593749dcbd T.J. Mercier 2025-06-25 202 * When a process obtains a dmabuf file descriptor, or maps a dmabuf, this
f44d593749dcbd T.J. Mercier 2025-06-25 203 * function attributes the provided @dmabuf to the @task. The first time @dmabuf
f44d593749dcbd T.J. Mercier 2025-06-25 204 * is attributed to @task, the buffer's size is added to the @task's dmabuf RSS.
f44d593749dcbd T.J. Mercier 2025-06-25 205 *
f44d593749dcbd T.J. Mercier 2025-06-25 206 * Return:
f44d593749dcbd T.J. Mercier 2025-06-25 207 * * 0 on success
f44d593749dcbd T.J. Mercier 2025-06-25 208 * * A negative error code upon error
f44d593749dcbd T.J. Mercier 2025-06-25 209 */
f44d593749dcbd T.J. Mercier 2025-06-25 210 int dma_buf_account_task(struct dma_buf *dmabuf, struct task_struct *task)
f44d593749dcbd T.J. Mercier 2025-06-25 211 {
f44d593749dcbd T.J. Mercier 2025-06-25 212 struct task_dma_buf_record *rec;
f44d593749dcbd T.J. Mercier 2025-06-25 213 int ret = 0;
f44d593749dcbd T.J. Mercier 2025-06-25 214
f44d593749dcbd T.J. Mercier 2025-06-25 215 if (!dmabuf || !task)
f44d593749dcbd T.J. Mercier 2025-06-25 216 return -EINVAL;
f44d593749dcbd T.J. Mercier 2025-06-25 217
f44d593749dcbd T.J. Mercier 2025-06-25 218 if (!task->dmabuf_info) {
f44d593749dcbd T.J. Mercier 2025-06-25 219 pr_err("%s dmabuf accounting record was not allocated\n", __func__);
f44d593749dcbd T.J. Mercier 2025-06-25 220 return -ENOMEM;
f44d593749dcbd T.J. Mercier 2025-06-25 221 }
f44d593749dcbd T.J. Mercier 2025-06-25 222
f44d593749dcbd T.J. Mercier 2025-06-25 @223 spin_lock(&task->dmabuf_info->lock);
f44d593749dcbd T.J. Mercier 2025-06-25 224 rec = find_task_dmabuf_record(task, dmabuf);
f44d593749dcbd T.J. Mercier 2025-06-25 225 if (!rec)
f44d593749dcbd T.J. Mercier 2025-06-25 @226 ret = new_task_dmabuf_record(task, dmabuf);
f44d593749dcbd T.J. Mercier 2025-06-25 227 else
f44d593749dcbd T.J. Mercier 2025-06-25 228 ++rec->refcnt;
f44d593749dcbd T.J. Mercier 2025-06-25 229 spin_unlock(&task->dmabuf_info->lock);
f44d593749dcbd T.J. Mercier 2025-06-25 230
f44d593749dcbd T.J. Mercier 2025-06-25 231 return ret;
f44d593749dcbd T.J. Mercier 2025-06-25 232 }
f44d593749dcbd T.J. Mercier 2025-06-25 233Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki