* [PATCH] Staging: lustre: Use kmemdup() instead of kzalloc and memcpy
@ 2018-06-17 11:16 ` Shreeya Patel
0 siblings, 0 replies; 4+ messages in thread
From: Shreeya Patel @ 2018-06-17 11:16 UTC (permalink / raw)
To: oleg.drokin, andreas.dilger, jsimmons, gregkh, lustre-devel,
devel, linux-kernel
Cc: Shreeya Patel
Replace calls to kzalloc or kmalloc followed by a memcpy with
a direct call to kmemdup to shorten the code.
The Coccinelle semantic patch used to make this change is as follows:
@@
expression from,to,size,flag;
statement S;
@@
- to = \(kmalloc\|kzalloc\)(size,flag);
+ to = kmemdup(from,size,flag);
if (to==NULL || ...) S
- memcpy(to, from, size);
Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
---
drivers/staging/lustre/lnet/lnet/api-ni.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index f9ed697..36ea14e 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -1271,15 +1271,14 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
lnd_tunables = (struct lnet_ioctl_config_lnd_tunables *)conf->cfg_bulk;
if (lnd_tunables) {
- ni->ni_lnd_tunables = kzalloc(sizeof(*ni->ni_lnd_tunables),
+ ni->ni_lnd_tunables = kmemdup(lnd_tunables,
+ sizeof(*ni->ni_lnd_tunables),
GFP_NOFS);
if (!ni->ni_lnd_tunables) {
mutex_unlock(&the_lnet.ln_lnd_mutex);
rc = -ENOMEM;
goto failed0;
}
- memcpy(ni->ni_lnd_tunables, lnd_tunables,
- sizeof(*ni->ni_lnd_tunables));
}
/*
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [lustre-devel] [PATCH] Staging: lustre: Use kmemdup() instead of kzalloc and memcpy
@ 2018-06-17 11:16 ` Shreeya Patel
0 siblings, 0 replies; 4+ messages in thread
From: Shreeya Patel @ 2018-06-17 11:16 UTC (permalink / raw)
To: oleg.drokin, andreas.dilger, jsimmons, gregkh, lustre-devel,
devel, linux-kernel
Cc: Shreeya Patel
Replace calls to kzalloc or kmalloc followed by a memcpy with
a direct call to kmemdup to shorten the code.
The Coccinelle semantic patch used to make this change is as follows:
@@
expression from,to,size,flag;
statement S;
@@
- to = \(kmalloc\|kzalloc\)(size,flag);
+ to = kmemdup(from,size,flag);
if (to==NULL || ...) S
- memcpy(to, from, size);
Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
---
drivers/staging/lustre/lnet/lnet/api-ni.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index f9ed697..36ea14e 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -1271,15 +1271,14 @@ lnet_startup_lndni(struct lnet_ni *ni, struct lnet_ioctl_config_data *conf)
lnd_tunables = (struct lnet_ioctl_config_lnd_tunables *)conf->cfg_bulk;
if (lnd_tunables) {
- ni->ni_lnd_tunables = kzalloc(sizeof(*ni->ni_lnd_tunables),
+ ni->ni_lnd_tunables = kmemdup(lnd_tunables,
+ sizeof(*ni->ni_lnd_tunables),
GFP_NOFS);
if (!ni->ni_lnd_tunables) {
mutex_unlock(&the_lnet.ln_lnd_mutex);
rc = -ENOMEM;
goto failed0;
}
- memcpy(ni->ni_lnd_tunables, lnd_tunables,
- sizeof(*ni->ni_lnd_tunables));
}
/*
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Staging: lustre: Use kmemdup() instead of kzalloc and memcpy
2018-06-17 11:16 ` [lustre-devel] " Shreeya Patel
@ 2018-06-17 11:22 ` Greg KH
-1 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2018-06-17 11:22 UTC (permalink / raw)
To: Shreeya Patel
Cc: oleg.drokin, andreas.dilger, jsimmons, lustre-devel, devel, linux-kernel
On Sun, Jun 17, 2018 at 04:46:55PM +0530, Shreeya Patel wrote:
> Replace calls to kzalloc or kmalloc followed by a memcpy with
> a direct call to kmemdup to shorten the code.
>
> The Coccinelle semantic patch used to make this change is as follows:
> @@
> expression from,to,size,flag;
> statement S;
> @@
>
> - to = \(kmalloc\|kzalloc\)(size,flag);
> + to = kmemdup(from,size,flag);
> if (to==NULL || ...) S
> - memcpy(to, from, size);
>
> Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
> ---
> drivers/staging/lustre/lnet/lnet/api-ni.c | 5 ++---
Always work off of the latest kernel tree. Ideally linux-next or the
staging.git staging-next tree. Worse case, Linus's tree. But never off
of an old kernel tree, that will only cause you to duplicate work that
others have done :(
Please resync against 4.18-rc1 and see why I say this when trying to
apply your patch...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
* [lustre-devel] [PATCH] Staging: lustre: Use kmemdup() instead of kzalloc and memcpy
@ 2018-06-17 11:22 ` Greg KH
0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2018-06-17 11:22 UTC (permalink / raw)
To: Shreeya Patel
Cc: oleg.drokin, andreas.dilger, jsimmons, lustre-devel, devel, linux-kernel
On Sun, Jun 17, 2018 at 04:46:55PM +0530, Shreeya Patel wrote:
> Replace calls to kzalloc or kmalloc followed by a memcpy with
> a direct call to kmemdup to shorten the code.
>
> The Coccinelle semantic patch used to make this change is as follows:
> @@
> expression from,to,size,flag;
> statement S;
> @@
>
> - to = \(kmalloc\|kzalloc\)(size,flag);
> + to = kmemdup(from,size,flag);
> if (to==NULL || ...) S
> - memcpy(to, from, size);
>
> Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com>
> ---
> drivers/staging/lustre/lnet/lnet/api-ni.c | 5 ++---
Always work off of the latest kernel tree. Ideally linux-next or the
staging.git staging-next tree. Worse case, Linus's tree. But never off
of an old kernel tree, that will only cause you to duplicate work that
others have done :(
Please resync against 4.18-rc1 and see why I say this when trying to
apply your patch...
thanks,
greg k-h
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-06-17 11:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-17 11:16 [PATCH] Staging: lustre: Use kmemdup() instead of kzalloc and memcpy Shreeya Patel
2018-06-17 11:16 ` [lustre-devel] " Shreeya Patel
2018-06-17 11:22 ` Greg KH
2018-06-17 11:22 ` [lustre-devel] " Greg KH
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.