public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup
@ 2015-05-30 10:22 Dighe, Niranjan (N.)
  2015-05-30 12:31 ` Julia Lawall
  2015-05-31  2:30 ` gregkh
  0 siblings, 2 replies; 6+ messages in thread
From: Dighe, Niranjan (N.) @ 2015-05-30 10:22 UTC (permalink / raw)
  To: oleg.drokin@intel.com, andreas.dilger@intel.com,
	gregkh@linuxfoundation.org, Julia.Lawall@lip6.fr,
	gdonald@gmail.com, rd@radekdostal.com, Dighe, Niranjan (N.),
	uja.ornl@gmail.com, joe@perches.com, HPDD-discuss@lists.01.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org

Replace kzalloc followed by memcpy by kmemdup. This patch was generated
by 'make coccicheck'

Signed-off-by: Niranjan Dighe <ndighe@visteon.com>

diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
index 0bda9c5..274cae3 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -866,29 +866,26 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,
 	INIT_LIST_HEAD(&lprof->lp_list);
 
 	LASSERT(proflen == (strlen(prof) + 1));
-	lprof->lp_profile = kzalloc(proflen, GFP_NOFS);
+	lprof->lp_profile = kmemdup(prof, proflen, GFP_NOFS);
 	if (lprof->lp_profile == NULL) {
 		err = -ENOMEM;
 		goto free_lprof;
 	}
-	memcpy(lprof->lp_profile, prof, proflen);
 
 	LASSERT(osclen == (strlen(osc) + 1));
-	lprof->lp_dt = kzalloc(osclen, GFP_NOFS);
+	lprof->lp_dt = kmemdup(osc, osclen, GFP_NOFS);
 	if (lprof->lp_dt == NULL) {
 		err = -ENOMEM;
 		goto free_lp_profile;
 	}
-	memcpy(lprof->lp_dt, osc, osclen);
 
 	if (mdclen > 0) {
 		LASSERT(mdclen == (strlen(mdc) + 1));
-		lprof->lp_md = kzalloc(mdclen, GFP_NOFS);
+		lprof->lp_md = kmemdup(mdc, mdclen, GFP_NOFS);
 		if (lprof->lp_md == NULL) {
 			err = -ENOMEM;
 			goto free_lp_dt;
 		}
-		memcpy(lprof->lp_md, mdc, mdclen);
 	}
 
 	list_add(&lprof->lp_list, &lustre_profile_list);
-- 
1.9.1

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

* Re: [PATCH] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup
  2015-05-30 10:22 Dighe, Niranjan (N.)
@ 2015-05-30 12:31 ` Julia Lawall
  2015-05-31  2:30 ` gregkh
  1 sibling, 0 replies; 6+ messages in thread
From: Julia Lawall @ 2015-05-30 12:31 UTC (permalink / raw)
  To: Dighe, Niranjan (N.)
  Cc: oleg.drokin@intel.com, andreas.dilger@intel.com,
	gregkh@linuxfoundation.org, Julia.Lawall@lip6.fr,
	gdonald@gmail.com, rd@radekdostal.com, uja.ornl@gmail.com,
	joe@perches.com, HPDD-discuss@lists.01.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org



On Sat, 30 May 2015, Dighe, Niranjan (N.) wrote:

> Replace kzalloc followed by memcpy by kmemdup. This patch was generated
> by 'make coccicheck'
>
> Signed-off-by: Niranjan Dighe <ndighe@visteon.com>

You need a --- here.  Also it is nice to put a diffstat below.

julia

>
> diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
> index 0bda9c5..274cae3 100644
> --- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
> +++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
> @@ -866,29 +866,26 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,
>  	INIT_LIST_HEAD(&lprof->lp_list);
>
>  	LASSERT(proflen == (strlen(prof) + 1));
> -	lprof->lp_profile = kzalloc(proflen, GFP_NOFS);
> +	lprof->lp_profile = kmemdup(prof, proflen, GFP_NOFS);
>  	if (lprof->lp_profile == NULL) {
>  		err = -ENOMEM;
>  		goto free_lprof;
>  	}
> -	memcpy(lprof->lp_profile, prof, proflen);
>
>  	LASSERT(osclen == (strlen(osc) + 1));
> -	lprof->lp_dt = kzalloc(osclen, GFP_NOFS);
> +	lprof->lp_dt = kmemdup(osc, osclen, GFP_NOFS);
>  	if (lprof->lp_dt == NULL) {
>  		err = -ENOMEM;
>  		goto free_lp_profile;
>  	}
> -	memcpy(lprof->lp_dt, osc, osclen);
>
>  	if (mdclen > 0) {
>  		LASSERT(mdclen == (strlen(mdc) + 1));
> -		lprof->lp_md = kzalloc(mdclen, GFP_NOFS);
> +		lprof->lp_md = kmemdup(mdc, mdclen, GFP_NOFS);
>  		if (lprof->lp_md == NULL) {
>  			err = -ENOMEM;
>  			goto free_lp_dt;
>  		}
> -		memcpy(lprof->lp_md, mdc, mdclen);
>  	}
>
>  	list_add(&lprof->lp_list, &lustre_profile_list);
> --
> 1.9.1
>

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

* [PATCH] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup
@ 2015-05-30 14:49 Dighe, Niranjan (N.)
  0 siblings, 0 replies; 6+ messages in thread
From: Dighe, Niranjan (N.) @ 2015-05-30 14:49 UTC (permalink / raw)
  To: Julia.Lawall@lip6.fr
  Cc: oleg.drokin@intel.com, andreas.dilger@intel.com,
	gregkh@linuxfoundation.org, gdonald@gmail.com, rd@radekdostal.com,
	Dighe, Niranjan (N.), uja.ornl@gmail.com, joe@perches.com,
	HPDD-discuss@lists.01.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org

Sure. I will correct and resend. 

Thanks,
Niranjan 

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

* [PATCH] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup
@ 2015-05-30 14:54 Dighe, Niranjan (N.)
  0 siblings, 0 replies; 6+ messages in thread
From: Dighe, Niranjan (N.) @ 2015-05-30 14:54 UTC (permalink / raw)
  To: Julia.Lawall@lip6.fr
  Cc: oleg.drokin@intel.com, andreas.dilger@intel.com,
	gregkh@linuxfoundation.org, gdonald@gmail.com, rd@radekdostal.com,
	Dighe, Niranjan (N.), uja.ornl@gmail.com, joe@perches.com,
	HPDD-discuss@lists.01.org, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org

Replace kzalloc followed by memcpy by kmemdup. This patch was generated
by 'make coccicheck'

Signed-off-by: Niranjan Dighe <ndighe@visteon.com>
---
drivers/staging/lustre/lustre/obdclass/obd_config.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
index 0bda9c5..274cae3 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -866,29 +866,26 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,
 	INIT_LIST_HEAD(&lprof->lp_list);
 
 	LASSERT(proflen == (strlen(prof) + 1));
-	lprof->lp_profile = kzalloc(proflen, GFP_NOFS);
+	lprof->lp_profile = kmemdup(prof, proflen, GFP_NOFS);
 	if (lprof->lp_profile == NULL) {
 		err = -ENOMEM;
 		goto free_lprof;
 	}
-	memcpy(lprof->lp_profile, prof, proflen);
 
 	LASSERT(osclen == (strlen(osc) + 1));
-	lprof->lp_dt = kzalloc(osclen, GFP_NOFS);
+	lprof->lp_dt = kmemdup(osc, osclen, GFP_NOFS);
 	if (lprof->lp_dt == NULL) {
 		err = -ENOMEM;
 		goto free_lp_profile;
 	}
-	memcpy(lprof->lp_dt, osc, osclen);
 
 	if (mdclen > 0) {
 		LASSERT(mdclen == (strlen(mdc) + 1));
-		lprof->lp_md = kzalloc(mdclen, GFP_NOFS);
+		lprof->lp_md = kmemdup(mdc, mdclen, GFP_NOFS);
 		if (lprof->lp_md == NULL) {
 			err = -ENOMEM;
 			goto free_lp_dt;
 		}
-		memcpy(lprof->lp_md, mdc, mdclen);
 	}
 
 	list_add(&lprof->lp_list, &lustre_profile_list);
-- 
1.9.1

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

* Re: [PATCH] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup
  2015-05-30 10:22 Dighe, Niranjan (N.)
  2015-05-30 12:31 ` Julia Lawall
@ 2015-05-31  2:30 ` gregkh
  1 sibling, 0 replies; 6+ messages in thread
From: gregkh @ 2015-05-31  2:30 UTC (permalink / raw)
  To: Dighe, Niranjan (N.)
  Cc: oleg.drokin@intel.com, andreas.dilger@intel.com,
	Julia.Lawall@lip6.fr, gdonald@gmail.com, rd@radekdostal.com,
	uja.ornl@gmail.com, joe@perches.com, HPDD-discuss@lists.01.org,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org

On Sat, May 30, 2015 at 10:22:17AM +0000, Dighe, Niranjan (N.) wrote:
> Replace kzalloc followed by memcpy by kmemdup. This patch was generated
> by 'make coccicheck'
> 
> Signed-off-by: Niranjan Dighe <ndighe@visteon.com>

Your name here doesn't match the name in the From: line of your email.

Please fix up your email client for all of the patches you sent me and
resend.

thanks,

greg k-h

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

* Re: [PATCH] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup
@ 2015-05-31  5:28 Dighe, Niranjan (N.)
  0 siblings, 0 replies; 6+ messages in thread
From: Dighe, Niranjan (N.) @ 2015-05-31  5:28 UTC (permalink / raw)
  To: gregkh@linuxfoundation.org
  Cc: devel@driverdev.osuosl.org, HPDD-discuss@lists.01.org,
	andreas.dilger@intel.com, gdonald@gmail.com, uja.ornl@gmail.com,
	rd@radekdostal.com, linux-kernel@vger.kernel.org,
	oleg.drokin@intel.com, Julia.Lawall@lip6.fr, joe@perches.com

Thanks Greg, I will send out a v2 of the patch with additional
"From: " in the email body as you suggested in the mail chain
with Madhu. 

Regards,
Niranjan 

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

end of thread, other threads:[~2015-05-31  5:28 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-30 14:49 [PATCH] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup Dighe, Niranjan (N.)
  -- strict thread matches above, loose matches on Subject: below --
2015-05-31  5:28 Dighe, Niranjan (N.)
2015-05-30 14:54 Dighe, Niranjan (N.)
2015-05-30 10:22 Dighe, Niranjan (N.)
2015-05-30 12:31 ` Julia Lawall
2015-05-31  2:30 ` gregkh

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