From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757786AbbE3Mbn (ORCPT ); Sat, 30 May 2015 08:31:43 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:64097 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757589AbbE3Mbh (ORCPT ); Sat, 30 May 2015 08:31:37 -0400 X-IronPort-AV: E=Sophos;i="5.13,522,1427752800"; d="scan'208";a="129807167" Date: Sat, 30 May 2015 14:31:31 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien 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" Subject: Re: [PATCH] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup In-Reply-To: <20150530102211.GA12727@codebox> Message-ID: References: <20150530102211.GA12727@codebox> User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: 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 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 >