public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-buf: propagate errors from dma_buf_describe() on debugfs read
@ 2016-06-17 18:57 Mathias Krause
  2016-06-19  8:45 ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Mathias Krause @ 2016-06-17 18:57 UTC (permalink / raw)
  To: Sumit Semwal
  Cc: linux-media, dri-devel, linaro-mm-sig, Mathias Krause,
	Daniel Vetter, PaX Team

The callback function dma_buf_describe() returns an int not void so the
function pointer cast in dma_buf_show() is wrong. dma_buf_describe() can
also fail when acquiring the mutex gets interrupted so always returning
0 in dma_buf_show() is wrong, too.

Fix both issues by casting the function pointer to the correct type and
propagate its return value.

This type mismatch was caught by the PaX RAP plugin.

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: PaX Team <pageexec@freemail.hu>
---
 drivers/dma-buf/dma-buf.c |    5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 6355ab38d630..0f2a4592fdd2 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -881,10 +881,9 @@ static int dma_buf_describe(struct seq_file *s)
 
 static int dma_buf_show(struct seq_file *s, void *unused)
 {
-	void (*func)(struct seq_file *) = s->private;
+	int (*func)(struct seq_file *) = s->private;
 
-	func(s);
-	return 0;
+	return func(s);
 }
 
 static int dma_buf_debug_open(struct inode *inode, struct file *file)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-buf: propagate errors from dma_buf_describe() on debugfs read
  2016-06-17 18:57 [PATCH] dma-buf: propagate errors from dma_buf_describe() on debugfs read Mathias Krause
@ 2016-06-19  8:45 ` Daniel Vetter
  2016-06-19 10:43   ` Mathias Krause
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Vetter @ 2016-06-19  8:45 UTC (permalink / raw)
  To: Mathias Krause
  Cc: Sumit Semwal, linux-media, dri-devel, linaro-mm-sig,
	Daniel Vetter, PaX Team

On Fri, Jun 17, 2016 at 08:57:03PM +0200, Mathias Krause wrote:
> The callback function dma_buf_describe() returns an int not void so the
> function pointer cast in dma_buf_show() is wrong. dma_buf_describe() can
> also fail when acquiring the mutex gets interrupted so always returning
> 0 in dma_buf_show() is wrong, too.
> 
> Fix both issues by casting the function pointer to the correct type and
> propagate its return value.
> 
> This type mismatch was caught by the PaX RAP plugin.
> 
> Signed-off-by: Mathias Krause <minipli@googlemail.com>
> Cc: Sumit Semwal <sumit.semwal@linaro.org>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Cc: PaX Team <pageexec@freemail.hu>
> ---
>  drivers/dma-buf/dma-buf.c |    5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
> index 6355ab38d630..0f2a4592fdd2 100644
> --- a/drivers/dma-buf/dma-buf.c
> +++ b/drivers/dma-buf/dma-buf.c
> @@ -881,10 +881,9 @@ static int dma_buf_describe(struct seq_file *s)
>  
>  static int dma_buf_show(struct seq_file *s, void *unused)
>  {
> -	void (*func)(struct seq_file *) = s->private;
> +	int (*func)(struct seq_file *) = s->private;
>  
> -	func(s);
> -	return 0;
> +	return func(s);

Probably even better to just nuke that indirection. Set this pointer to
NULL and inline dma_buf_describe into dma_buf_show.
-Daniel

>  }
>  
>  static int dma_buf_debug_open(struct inode *inode, struct file *file)
> -- 
> 1.7.10.4
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-buf: propagate errors from dma_buf_describe() on debugfs read
  2016-06-19  8:45 ` Daniel Vetter
@ 2016-06-19 10:43   ` Mathias Krause
  0 siblings, 0 replies; 3+ messages in thread
From: Mathias Krause @ 2016-06-19 10:43 UTC (permalink / raw)
  To: Daniel Vetter
  Cc: Sumit Semwal, linux-media, dri-devel, linaro-mm-sig,
	Daniel Vetter, PaX Team

On 19 June 2016 at 10:45, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Fri, Jun 17, 2016 at 08:57:03PM +0200, Mathias Krause wrote:
>> diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
>> index 6355ab38d630..0f2a4592fdd2 100644
>> --- a/drivers/dma-buf/dma-buf.c
>> +++ b/drivers/dma-buf/dma-buf.c
>> @@ -881,10 +881,9 @@ static int dma_buf_describe(struct seq_file *s)
>>
>>  static int dma_buf_show(struct seq_file *s, void *unused)
>>  {
>> -     void (*func)(struct seq_file *) = s->private;
>> +     int (*func)(struct seq_file *) = s->private;
>>
>> -     func(s);
>> -     return 0;
>> +     return func(s);
>
> Probably even better to just nuke that indirection. Set this pointer to
> NULL and inline dma_buf_describe into dma_buf_show.

Even further, we can get rid of dma_buf_debugfs_create_file() too as
it's only used to create this indirection.
I'll send a v2 just doing that.

Thanks,
Mathias

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-06-19 10:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-17 18:57 [PATCH] dma-buf: propagate errors from dma_buf_describe() on debugfs read Mathias Krause
2016-06-19  8:45 ` Daniel Vetter
2016-06-19 10:43   ` Mathias Krause

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox