Skip to content

Commit ef3a6b7

Browse files
Charan Teja ReddyChristianKoenigAMD
authored andcommitted
dma-buf: call dma_buf_stats_setup after dmabuf is in valid list
When dma_buf_stats_setup() fails, it closes the dmabuf file which results into the calling of dma_buf_file_release() where it does list_del(&dmabuf->list_node) with out first adding it to the proper list. This is resulting into panic in the below path: __list_del_entry_valid+0x38/0xac dma_buf_file_release+0x74/0x158 __fput+0xf4/0x428 ____fput+0x14/0x24 task_work_run+0x178/0x24c do_notify_resume+0x194/0x264 work_pending+0xc/0x5f0 Fix it by moving the dma_buf_stats_setup() after dmabuf is added to the list. Fixes: bdb8d06 ("dmabuf: Add the capability to expose DMA-BUF stats in sysfs") Signed-off-by: Charan Teja Reddy <quic_charante@quicinc.com> Tested-by: T.J. Mercier <tjmercier@google.com> Acked-by: T.J. Mercier <tjmercier@google.com> Cc: <stable@vger.kernel.org> # 5.15.x+ Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Christian König <christian.koenig@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/1652125797-2043-1-git-send-email-quic_charante@quicinc.com
1 parent 1b5853d commit ef3a6b7

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/dma-buf/dma-buf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,17 +543,17 @@ struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info)
543543
file->f_mode |= FMODE_LSEEK;
544544
dmabuf->file = file;
545545

546-
ret = dma_buf_stats_setup(dmabuf);
547-
if (ret)
548-
goto err_sysfs;
549-
550546
mutex_init(&dmabuf->lock);
551547
INIT_LIST_HEAD(&dmabuf->attachments);
552548

553549
mutex_lock(&db_list.lock);
554550
list_add(&dmabuf->list_node, &db_list.head);
555551
mutex_unlock(&db_list.lock);
556552

553+
ret = dma_buf_stats_setup(dmabuf);
554+
if (ret)
555+
goto err_sysfs;
556+
557557
return dmabuf;
558558

559559
err_sysfs:

0 commit comments

Comments
 (0)