* [PATCH] xen: use struct_size() helper in kzalloc()
@ 2019-04-03 5:26 Andrea Righi
2019-04-03 6:00 ` Juergen Gross
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Andrea Righi @ 2019-04-03 5:26 UTC (permalink / raw)
To: Boris Ostrovsky, Juergen Gross
Cc: Stefano Stabellini, xen-devel, linux-kernel
struct privcmd_buf_vma_private has a zero-sized array at the end
(pages), use the new struct_size() helper to determine the proper
allocation size and avoid potential type mistakes.
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
---
drivers/xen/privcmd-buf.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/xen/privcmd-buf.c b/drivers/xen/privcmd-buf.c
index de01a6d0059d..a1c61e351d3f 100644
--- a/drivers/xen/privcmd-buf.c
+++ b/drivers/xen/privcmd-buf.c
@@ -140,8 +140,7 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma)
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
- vma_priv = kzalloc(sizeof(*vma_priv) + count * sizeof(void *),
- GFP_KERNEL);
+ vma_priv = kzalloc(struct_size(vma_priv, pages, count), GFP_KERNEL);
if (!vma_priv)
return -ENOMEM;
--
2.19.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH] xen: use struct_size() helper in kzalloc()
@ 2019-04-03 5:26 Andrea Righi
0 siblings, 0 replies; 7+ messages in thread
From: Andrea Righi @ 2019-04-03 5:26 UTC (permalink / raw)
To: Boris Ostrovsky, Juergen Gross
Cc: xen-devel, Stefano Stabellini, linux-kernel
struct privcmd_buf_vma_private has a zero-sized array at the end
(pages), use the new struct_size() helper to determine the proper
allocation size and avoid potential type mistakes.
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
---
drivers/xen/privcmd-buf.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/xen/privcmd-buf.c b/drivers/xen/privcmd-buf.c
index de01a6d0059d..a1c61e351d3f 100644
--- a/drivers/xen/privcmd-buf.c
+++ b/drivers/xen/privcmd-buf.c
@@ -140,8 +140,7 @@ static int privcmd_buf_mmap(struct file *file, struct vm_area_struct *vma)
if (!(vma->vm_flags & VM_SHARED))
return -EINVAL;
- vma_priv = kzalloc(sizeof(*vma_priv) + count * sizeof(void *),
- GFP_KERNEL);
+ vma_priv = kzalloc(struct_size(vma_priv, pages, count), GFP_KERNEL);
if (!vma_priv)
return -ENOMEM;
--
2.19.1
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] xen: use struct_size() helper in kzalloc()
2019-04-03 5:26 [PATCH] xen: use struct_size() helper in kzalloc() Andrea Righi
2019-04-03 6:00 ` Juergen Gross
@ 2019-04-03 6:00 ` Juergen Gross
2019-04-05 6:48 ` Juergen Gross
2019-04-05 6:48 ` Juergen Gross
3 siblings, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2019-04-03 6:00 UTC (permalink / raw)
To: Andrea Righi, Boris Ostrovsky; +Cc: xen-devel, Stefano Stabellini, linux-kernel
On 03/04/2019 07:26, Andrea Righi wrote:
> struct privcmd_buf_vma_private has a zero-sized array at the end
> (pages), use the new struct_size() helper to determine the proper
> allocation size and avoid potential type mistakes.
>
> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] xen: use struct_size() helper in kzalloc()
2019-04-03 5:26 [PATCH] xen: use struct_size() helper in kzalloc() Andrea Righi
@ 2019-04-03 6:00 ` Juergen Gross
2019-04-03 6:00 ` Juergen Gross
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2019-04-03 6:00 UTC (permalink / raw)
To: Andrea Righi, Boris Ostrovsky; +Cc: Stefano Stabellini, xen-devel, linux-kernel
On 03/04/2019 07:26, Andrea Righi wrote:
> struct privcmd_buf_vma_private has a zero-sized array at the end
> (pages), use the new struct_size() helper to determine the proper
> allocation size and avoid potential type mistakes.
>
> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Juergen
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] xen: use struct_size() helper in kzalloc()
2019-04-03 5:26 [PATCH] xen: use struct_size() helper in kzalloc() Andrea Righi
` (2 preceding siblings ...)
2019-04-05 6:48 ` Juergen Gross
@ 2019-04-05 6:48 ` Juergen Gross
3 siblings, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2019-04-05 6:48 UTC (permalink / raw)
To: Andrea Righi, Boris Ostrovsky; +Cc: xen-devel, Stefano Stabellini, linux-kernel
On 03/04/2019 07:26, Andrea Righi wrote:
> struct privcmd_buf_vma_private has a zero-sized array at the end
> (pages), use the new struct_size() helper to determine the proper
> allocation size and avoid potential type mistakes.
>
> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Pushed to xen/tip.git for-linus-5.1b
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Xen-devel] [PATCH] xen: use struct_size() helper in kzalloc()
2019-04-03 5:26 [PATCH] xen: use struct_size() helper in kzalloc() Andrea Righi
@ 2019-04-05 6:48 ` Juergen Gross
2019-04-03 6:00 ` Juergen Gross
` (2 subsequent siblings)
3 siblings, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2019-04-05 6:48 UTC (permalink / raw)
To: Andrea Righi, Boris Ostrovsky; +Cc: xen-devel, Stefano Stabellini, linux-kernel
On 03/04/2019 07:26, Andrea Righi wrote:
> struct privcmd_buf_vma_private has a zero-sized array at the end
> (pages), use the new struct_size() helper to determine the proper
> allocation size and avoid potential type mistakes.
>
> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Pushed to xen/tip.git for-linus-5.1b
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] xen: use struct_size() helper in kzalloc()
@ 2019-04-05 6:48 ` Juergen Gross
0 siblings, 0 replies; 7+ messages in thread
From: Juergen Gross @ 2019-04-05 6:48 UTC (permalink / raw)
To: Andrea Righi, Boris Ostrovsky; +Cc: Stefano Stabellini, xen-devel, linux-kernel
On 03/04/2019 07:26, Andrea Righi wrote:
> struct privcmd_buf_vma_private has a zero-sized array at the end
> (pages), use the new struct_size() helper to determine the proper
> allocation size and avoid potential type mistakes.
>
> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Pushed to xen/tip.git for-linus-5.1b
Juergen
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-04-05 6:48 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-03 5:26 [PATCH] xen: use struct_size() helper in kzalloc() Andrea Righi
2019-04-03 6:00 ` Juergen Gross
2019-04-03 6:00 ` Juergen Gross
2019-04-05 6:48 ` [Xen-devel] " Juergen Gross
2019-04-05 6:48 ` Juergen Gross
2019-04-05 6:48 ` Juergen Gross
-- strict thread matches above, loose matches on Subject: below --
2019-04-03 5:26 Andrea Righi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.