public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Dighe, Niranjan (N.)" <ndighe@visteon.com>
To: "oleg.drokin@intel.com" <oleg.drokin@intel.com>,
	"andreas.dilger@intel.com" <andreas.dilger@intel.com>,
	"gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"Julia.Lawall@lip6.fr" <Julia.Lawall@lip6.fr>,
	"gdonald@gmail.com" <gdonald@gmail.com>,
	"rd@radekdostal.com" <rd@radekdostal.com>,
	"Dighe, Niranjan (N.)" <ndighe@visteon.com>,
	"uja.ornl@gmail.com" <uja.ornl@gmail.com>,
	"joe@perches.com" <joe@perches.com>,
	"HPDD-discuss@lists.01.org" <HPDD-discuss@ml01.01.org>,
	"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup
Date: Sat, 30 May 2015 10:22:17 +0000	[thread overview]
Message-ID: <20150530102211.GA12727@codebox> (raw)

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

             reply	other threads:[~2015-05-30 10:38 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150530102211.GA12727@codebox \
    --to=ndighe@visteon.com \
    --cc=HPDD-discuss@ml01.01.org \
    --cc=Julia.Lawall@lip6.fr \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gdonald@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oleg.drokin@intel.com \
    --cc=rd@radekdostal.com \
    --cc=uja.ornl@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox