* [PATCH] [media] videobuf-dma-contig: NULL check for vb2_plane_cookie
@ 2014-12-11 13:07 Nikhil Devshatwar
2014-12-11 14:56 ` Sakari Ailus
0 siblings, 1 reply; 3+ messages in thread
From: Nikhil Devshatwar @ 2014-12-11 13:07 UTC (permalink / raw)
To: linux-media; +Cc: Nikhil Devshatwar
vb2_plane_cookie can return NULL if the plane no is greater than
total no of planes or when mem_ops are absent.
Add NULL check to avoid NULL pointer crash in the kernel.
Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
---
include/media/videobuf2-dma-contig.h | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/media/videobuf2-dma-contig.h b/include/media/videobuf2-dma-contig.h
index 8197f87..5efc56e 100644
--- a/include/media/videobuf2-dma-contig.h
+++ b/include/media/videobuf2-dma-contig.h
@@ -21,7 +21,10 @@ vb2_dma_contig_plane_dma_addr(struct vb2_buffer *vb, unsigned int plane_no)
{
dma_addr_t *addr = vb2_plane_cookie(vb, plane_no);
- return *addr;
+ if (addr == NULL)
+ return addr;
+ else
+ return *addr;
}
void *vb2_dma_contig_init_ctx(struct device *dev);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] [media] videobuf-dma-contig: NULL check for vb2_plane_cookie
2014-12-11 13:07 [PATCH] [media] videobuf-dma-contig: NULL check for vb2_plane_cookie Nikhil Devshatwar
@ 2014-12-11 14:56 ` Sakari Ailus
2014-12-19 11:06 ` Hans Verkuil
0 siblings, 1 reply; 3+ messages in thread
From: Sakari Ailus @ 2014-12-11 14:56 UTC (permalink / raw)
To: Nikhil Devshatwar; +Cc: linux-media
Hi Nikhil,
On Thu, Dec 11, 2014 at 06:37:22PM +0530, Nikhil Devshatwar wrote:
> vb2_plane_cookie can return NULL if the plane no is greater than
> total no of planes or when mem_ops are absent.
>
> Add NULL check to avoid NULL pointer crash in the kernel.
>
> Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
> ---
> include/media/videobuf2-dma-contig.h | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/include/media/videobuf2-dma-contig.h b/include/media/videobuf2-dma-contig.h
> index 8197f87..5efc56e 100644
> --- a/include/media/videobuf2-dma-contig.h
> +++ b/include/media/videobuf2-dma-contig.h
> @@ -21,7 +21,10 @@ vb2_dma_contig_plane_dma_addr(struct vb2_buffer *vb, unsigned int plane_no)
> {
> dma_addr_t *addr = vb2_plane_cookie(vb, plane_no);
>
> - return *addr;
> + if (addr == NULL)
> + return addr;
> + else
> + return *addr;
> }
>
> void *vb2_dma_contig_init_ctx(struct device *dev);
Should this happen? Wouldn't it be a bug somewhere, quite possibly the driver?
--
Kind regards,
Sakari Ailus
e-mail: sakari.ailus@iki.fi XMPP: sailus@retiisi.org.uk
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [media] videobuf-dma-contig: NULL check for vb2_plane_cookie
2014-12-11 14:56 ` Sakari Ailus
@ 2014-12-19 11:06 ` Hans Verkuil
0 siblings, 0 replies; 3+ messages in thread
From: Hans Verkuil @ 2014-12-19 11:06 UTC (permalink / raw)
To: Sakari Ailus, Nikhil Devshatwar; +Cc: linux-media
Hi Nikhil,
On 12/11/2014 03:56 PM, Sakari Ailus wrote:
> Hi Nikhil,
>
> On Thu, Dec 11, 2014 at 06:37:22PM +0530, Nikhil Devshatwar wrote:
>> vb2_plane_cookie can return NULL if the plane no is greater than
>> total no of planes or when mem_ops are absent.
>>
>> Add NULL check to avoid NULL pointer crash in the kernel.
>>
>> Signed-off-by: Nikhil Devshatwar <nikhil.nd@ti.com>
>> ---
>> include/media/videobuf2-dma-contig.h | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/media/videobuf2-dma-contig.h b/include/media/videobuf2-dma-contig.h
>> index 8197f87..5efc56e 100644
>> --- a/include/media/videobuf2-dma-contig.h
>> +++ b/include/media/videobuf2-dma-contig.h
>> @@ -21,7 +21,10 @@ vb2_dma_contig_plane_dma_addr(struct vb2_buffer *vb, unsigned int plane_no)
>> {
>> dma_addr_t *addr = vb2_plane_cookie(vb, plane_no);
>>
>> - return *addr;
>> + if (addr == NULL)
>> + return addr;
>> + else
>> + return *addr;
How about:
return addr ? *addr : NULL;
Much better.
>> }
>>
>> void *vb2_dma_contig_init_ctx(struct device *dev);
>
> Should this happen? Wouldn't it be a bug somewhere, quite possibly the driver?
>
I agree with Sakari: could this ever happen in practice unless it is a driver bug?
If you can provide an example, then that would help.
Regards,
Hans
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-12-19 11:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-11 13:07 [PATCH] [media] videobuf-dma-contig: NULL check for vb2_plane_cookie Nikhil Devshatwar
2014-12-11 14:56 ` Sakari Ailus
2014-12-19 11:06 ` Hans Verkuil
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).