From d8fbe341beb617ebb22b98fb893e4aa32ae2d864 Mon Sep 17 00:00:00 2001 From: Sumit Semwal Date: Fri, 23 Jan 2015 12:53:43 +0530 Subject: dma-buf: cleanup dma_buf_export() to make it easily extensible At present, dma_buf_export() takes a series of parameters, which makes it difficult to add any new parameters for exporters, if required. Make it simpler by moving all these parameters into a struct, and pass the struct * as parameter to dma_buf_export(). While at it, unite dma_buf_export_named() with dma_buf_export(), and change all callers accordingly. Reviewed-by: Maarten Lankhorst Reviewed-by: Daniel Thompson Acked-by: Mauro Carvalho Chehab Acked-by: Dave Airlie Signed-off-by: Sumit Semwal --- drivers/staging/android/ion/ion.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 0e3d8c7..b94d69f 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -1106,6 +1106,12 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client, struct ion_buffer *buffer; struct dma_buf *dmabuf; bool valid_handle; + DEFINE_DMA_BUF_EXPORT_INFO(exp_info); + + exp_info.ops = &dma_buf_ops; + exp_info.size = buffer->size; + exp_info.flags = O_RDWR; + exp_info.priv = buffer; mutex_lock(&client->lock); valid_handle = ion_handle_validate(client, handle); @@ -1118,8 +1124,7 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client, ion_buffer_get(buffer); mutex_unlock(&client->lock); - dmabuf = dma_buf_export(buffer, &dma_buf_ops, buffer->size, O_RDWR, - NULL); + dmabuf = dma_buf_export(&exp_info); if (IS_ERR(dmabuf)) { ion_buffer_put(buffer); return dmabuf; -- cgit v1.1 From 72449cb47b0104c32ff8fb9380ade9113375d8d1 Mon Sep 17 00:00:00 2001 From: Sumit Semwal Date: Sat, 21 Feb 2015 09:00:17 +0530 Subject: staging: android: ion: fix wrong init of dma_buf_export_info Fixes: 817bd7253291 ("dma-buf: cleanup dma_buf_export() to make it easily extensible") Stupid copy-paste from me in the above patch leads to the following static checker warning: drivers/staging/android/ion/ion.c:1112 ion_share_dma_buf() error: potentially dereferencing uninitialized 'buffer'. drivers/staging/android/ion/ion.c 1103 struct dma_buf *ion_share_dma_buf(struct ion_client *client, 1104 struct ion_handle *handle) 1105 { 1106 struct ion_buffer *buffer; ^^^^^^ 1107 struct dma_buf *dmabuf; 1108 bool valid_handle; 1109 DEFINE_DMA_BUF_EXPORT_INFO(exp_info); 1110 1111 exp_info.ops = &dma_buf_ops; 1112 exp_info.size = buffer->size; ^^^^^^ 1113 exp_info.flags = O_RDWR; 1114 exp_info.priv = buffer; ^^^^^^ And here also. 1115 This patch corrects this stupidity. Reported-by: Dan Carpenter Reviewed-by: Dan Carpenter Acked-by: Greg Kroah-Hartman Signed-off-by: Sumit Semwal --- drivers/staging/android/ion/ion.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index b94d69f..b0b96ab 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -1108,11 +1108,6 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client, bool valid_handle; DEFINE_DMA_BUF_EXPORT_INFO(exp_info); - exp_info.ops = &dma_buf_ops; - exp_info.size = buffer->size; - exp_info.flags = O_RDWR; - exp_info.priv = buffer; - mutex_lock(&client->lock); valid_handle = ion_handle_validate(client, handle); if (!valid_handle) { @@ -1124,6 +1119,11 @@ struct dma_buf *ion_share_dma_buf(struct ion_client *client, ion_buffer_get(buffer); mutex_unlock(&client->lock); + exp_info.ops = &dma_buf_ops; + exp_info.size = buffer->size; + exp_info.flags = O_RDWR; + exp_info.priv = buffer; + dmabuf = dma_buf_export(&exp_info); if (IS_ERR(dmabuf)) { ion_buffer_put(buffer); -- cgit v1.1