* [PATCH] staging: lusture: libcfs: Prefer kmalloc_array over kmalloc
@ 2016-02-21 11:18 Bhaktipriya Shridhar
2016-02-21 12:26 ` [Outreachy kernel] " Julia Lawall
2016-02-26 6:37 ` Greg KH
0 siblings, 2 replies; 4+ messages in thread
From: Bhaktipriya Shridhar @ 2016-02-21 11:18 UTC (permalink / raw)
To: outreachy-kernel
Use kmalloc_array instead of kmalloc for arrays to prevent integer
overflows.
This was done using Coccinelle:
@@
expression e1, e2;
constant C;
type t;
@@
(
- kmalloc(sizeof(e1)*e2, C)
+ kmalloc_array(e2, sizeof(e1), C)
|
- kmalloc(e2*sizeof(e1), C)
+ kmalloc_array(e2, sizeof(e1), C)
|
- kmalloc(e2*sizeof(t), C)
+ kmalloc_array(e2, sizeof(t), C)
|
- kmalloc(sizeof(t)*e2, C)
+ kmalloc_array(e2, sizeof(t), C)
)
Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
---
drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
index 91c2ae8..dda7e3a 100644
--- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
+++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
@@ -61,8 +61,9 @@ int cfs_tracefile_init_arch(void)
memset(cfs_trace_data, 0, sizeof(cfs_trace_data));
for (i = 0; i < CFS_TCD_TYPE_MAX; i++) {
cfs_trace_data[i] =
- kmalloc(sizeof(union cfs_trace_data_union) *
- num_possible_cpus(), GFP_KERNEL);
+ kmalloc_array(num_possible_cpus(),
+ sizeof(union cfs_trace_data_union),
+ GFP_KERNEL);
if (!cfs_trace_data[i])
goto out;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: lusture: libcfs: Prefer kmalloc_array over kmalloc
2016-02-21 11:18 [PATCH] staging: lusture: libcfs: Prefer kmalloc_array over kmalloc Bhaktipriya Shridhar
@ 2016-02-21 12:26 ` Julia Lawall
2016-02-26 6:37 ` Greg KH
1 sibling, 0 replies; 4+ messages in thread
From: Julia Lawall @ 2016-02-21 12:26 UTC (permalink / raw)
To: Bhaktipriya Shridhar; +Cc: outreachy-kernel
On Sun, 21 Feb 2016, Bhaktipriya Shridhar wrote:
> Use kmalloc_array instead of kmalloc for arrays to prevent integer
> overflows.
I guess that this number (num_possible_spus()) is not likely to cause an
overflow in the near future.
julia
> This was done using Coccinelle:
>
> @@
> expression e1, e2;
> constant C;
> type t;
> @@
> (
> - kmalloc(sizeof(e1)*e2, C)
> + kmalloc_array(e2, sizeof(e1), C)
> |
> - kmalloc(e2*sizeof(e1), C)
> + kmalloc_array(e2, sizeof(e1), C)
> |
> - kmalloc(e2*sizeof(t), C)
> + kmalloc_array(e2, sizeof(t), C)
> |
> - kmalloc(sizeof(t)*e2, C)
> + kmalloc_array(e2, sizeof(t), C)
> )
>
> Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
> ---
> drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
> index 91c2ae8..dda7e3a 100644
> --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
> +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
> @@ -61,8 +61,9 @@ int cfs_tracefile_init_arch(void)
> memset(cfs_trace_data, 0, sizeof(cfs_trace_data));
> for (i = 0; i < CFS_TCD_TYPE_MAX; i++) {
> cfs_trace_data[i] =
> - kmalloc(sizeof(union cfs_trace_data_union) *
> - num_possible_cpus(), GFP_KERNEL);
> + kmalloc_array(num_possible_cpus(),
> + sizeof(union cfs_trace_data_union),
> + GFP_KERNEL);
> if (!cfs_trace_data[i])
> goto out;
> }
> --
> 2.1.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160221111815.GA27645%40Karyakshetra.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: lusture: libcfs: Prefer kmalloc_array over kmalloc
2016-02-21 11:18 [PATCH] staging: lusture: libcfs: Prefer kmalloc_array over kmalloc Bhaktipriya Shridhar
2016-02-21 12:26 ` [Outreachy kernel] " Julia Lawall
@ 2016-02-26 6:37 ` Greg KH
2016-02-28 11:58 ` Bhaktipriya Shridhar
1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2016-02-26 6:37 UTC (permalink / raw)
To: Bhaktipriya Shridhar; +Cc: outreachy-kernel
On Sun, Feb 21, 2016 at 04:48:15PM +0530, Bhaktipriya Shridhar wrote:
> Use kmalloc_array instead of kmalloc for arrays to prevent integer
> overflows.
> This was done using Coccinelle:
>
> @@
> expression e1, e2;
> constant C;
> type t;
> @@
> (
> - kmalloc(sizeof(e1)*e2, C)
> + kmalloc_array(e2, sizeof(e1), C)
> |
> - kmalloc(e2*sizeof(e1), C)
> + kmalloc_array(e2, sizeof(e1), C)
> |
> - kmalloc(e2*sizeof(t), C)
> + kmalloc_array(e2, sizeof(t), C)
> |
> - kmalloc(sizeof(t)*e2, C)
> + kmalloc_array(e2, sizeof(t), C)
> )
>
> Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
> ---
> drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
You have sent a bunch of "lustre" patches with a typo in the subject
line, making my filter miss them, so I've applied a bunch of other
patches from other developers, and most of these don't apply anymore :(
Can you please fix this up, rebase any outstanding patches you have made
for this part of the kernel tree (drivers/staging/lustre/) and resend
them?
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Outreachy kernel] [PATCH] staging: lusture: libcfs: Prefer kmalloc_array over kmalloc
2016-02-26 6:37 ` Greg KH
@ 2016-02-28 11:58 ` Bhaktipriya Shridhar
0 siblings, 0 replies; 4+ messages in thread
From: Bhaktipriya Shridhar @ 2016-02-28 11:58 UTC (permalink / raw)
To: Greg KH; +Cc: outreachy-kernel
Hello Greg,
I have re-sent all my lustre patches with the typo fixed. Please have a look.
Thanks,
Bhaktipriya
On Fri, Feb 26, 2016 at 12:07 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> On Sun, Feb 21, 2016 at 04:48:15PM +0530, Bhaktipriya Shridhar wrote:
>> Use kmalloc_array instead of kmalloc for arrays to prevent integer
>> overflows.
>> This was done using Coccinelle:
>>
>> @@
>> expression e1, e2;
>> constant C;
>> type t;
>> @@
>> (
>> - kmalloc(sizeof(e1)*e2, C)
>> + kmalloc_array(e2, sizeof(e1), C)
>> |
>> - kmalloc(e2*sizeof(e1), C)
>> + kmalloc_array(e2, sizeof(e1), C)
>> |
>> - kmalloc(e2*sizeof(t), C)
>> + kmalloc_array(e2, sizeof(t), C)
>> |
>> - kmalloc(sizeof(t)*e2, C)
>> + kmalloc_array(e2, sizeof(t), C)
>> )
>>
>> Signed-off-by: Bhaktipriya Shridhar <bhaktipriya96@gmail.com>
>> ---
>> drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> You have sent a bunch of "lustre" patches with a typo in the subject
> line, making my filter miss them, so I've applied a bunch of other
> patches from other developers, and most of these don't apply anymore :(
>
> Can you please fix this up, rebase any outstanding patches you have made
> for this part of the kernel tree (drivers/staging/lustre/) and resend
> them?
>
> thanks,
>
> greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-02-28 11:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-21 11:18 [PATCH] staging: lusture: libcfs: Prefer kmalloc_array over kmalloc Bhaktipriya Shridhar
2016-02-21 12:26 ` [Outreachy kernel] " Julia Lawall
2016-02-26 6:37 ` Greg KH
2016-02-28 11:58 ` Bhaktipriya Shridhar
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.