dma-buf: add ref counting for module as exporter
authorSumit Semwal <sumit.semwal@linaro.org>
Tue, 5 May 2015 09:26:15 +0000 (14:56 +0530)
committerSumit Semwal <sumit.semwal@linaro.org>
Wed, 13 May 2015 09:05:57 +0000 (14:35 +0530)
commit9abdffe286c1532a54d5aee31571d3029be4026c
tree9a2651def7b2ffea3b4fcb78b8ec0a38e460ab46
parent5ebe6afaf0057ac3eaeb98defd5456894b446d22
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
drivers/dma-buf/dma-buf.c
include/linux/dma-buf.h