提交 67a5d0ce 编写于 作者: T Tomasz Stanislawski 提交者: Mauro Carvalho Chehab

[media] v4l: vb2-dma-contig: add reference counting for a device from allocator context

This patch adds taking reference to the device for MMAP buffers.
Such buffers, may be exported using DMABUF mechanism. If the driver that
created a queue is unloaded then the queue is released, the device might be
released too.  However, buffers cannot be released if they are referenced by
DMABUF descriptor(s). The device pointer kept in a buffer must be valid for the
whole buffer's lifetime. Therefore MMAP buffers should take a reference to the
device to avoid risk of dangling pointers.
Signed-off-by: NTomasz Stanislawski <t.stanislaws@samsung.com>
Acked-by: NHans Verkuil <hans.verkuil@cisco.com>
Acked-by: NLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Tested-by: NMauro Carvalho Chehab <mchehab@redhat.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 9ef2cbeb
无相关合并请求
......@@ -148,6 +148,7 @@ static void vb2_dc_put(void *buf_priv)
kfree(buf->sgt_base);
}
dma_free_coherent(buf->dev, buf->size, buf->vaddr, buf->dma_addr);
put_device(buf->dev);
kfree(buf);
}
......@@ -168,7 +169,8 @@ static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size)
return ERR_PTR(-ENOMEM);
}
buf->dev = dev;
/* Prevent the device from being released while the buffer is used */
buf->dev = get_device(dev);
buf->size = size;
buf->handler.refcount = &buf->refcount;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
反馈
建议
客服 返回
顶部