dma-buf: add ref counting for module as exporter 24/115824/1
authorSumit Semwal <sumit.semwal@linaro.org>
Tue, 5 May 2015 09:26:15 +0000 (14:56 +0530)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Tue, 21 Feb 2017 11:05:20 +0000 (12:05 +0100)
commit2e6e65b9100c61b9eb356cd87076596a27b421f6
tree8f4921ae75e00f17c0fa5ebc3aedd53803cdcc9f
parent2582e4d639d7c4712e4d45422f0180888516c91d
dma-buf: add ref counting for module as exporter

Add reference counting on a kernel module that exports dma-buf and
implements its operations. This prevents the module from being unloaded
while DMABUF file is in use.

The original patch [1] was submitted by Tomasz Stanislawski, but this
is a simpler way to do it.

v3: call module_put() as late as possible, per gregkh's comment.
v2: move owner to struct dma_buf, and use DEFINE_DMA_BUF_EXPORT_INFO
    macro to simplify the change.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
[1]: https://lkml.org/lkml/2012/8/8/163

[backport from mainline commit 9abdffe286c1532a54d5aee31571d3029be4026c]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: I05cd9440f26222f877a8bfa2313a6b757419f682
drivers/dma-buf/dma-buf.c
include/linux/dma-buf.h