From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757354AbbEaFjQ (ORCPT ); Sun, 31 May 2015 01:39:16 -0400 Received: from mail-am1on0102.outbound.protection.outlook.com ([157.56.112.102]:61114 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750744AbbEaFjL convert rfc822-to-8bit (ORCPT ); Sun, 31 May 2015 01:39:11 -0400 From: "Dighe, Niranjan (N.)" 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" Subject: [PATCH v2] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup Thread-Topic: [PATCH v2] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup Thread-Index: AQHQm2Qc8VZxia9JWUGOaf91xDaoFg== Date: Sun, 31 May 2015 05:39:07 +0000 Message-ID: <20150531053902.GA3100@codebox> Reply-To: "20150531052817.GA3043@codebox" <20150531052817.GA3043@codebox> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=ndighe@visteon.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [45.114.60.9] x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DBXPR06MB612; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(520003)(5005006)(3002001);SRVR:DBXPR06MB612;BCL:0;PCL:0;RULEID:;SRVR:DBXPR06MB612; x-forefront-prvs: 0593E261C4 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(199003)(43066003)(46102003)(2900100001)(102836002)(33716001)(19580405001)(19580395003)(64706001)(229853001)(2351001)(68736005)(81156007)(4001540100001)(106356001)(2656002)(33656002)(66066001)(87936001)(101416001)(106116001)(50986999)(54356999)(53806999)(77156002)(5002640100001)(5001860100001)(189998001)(86362001)(62966003)(2501003)(2860100001)(105586002)(97736004)(5001920100001)(5001830100001)(5001960100002)(122556002)(40100003)(110136002)(13693001);DIR:OUT;SFP:1102;SCL:1;SRVR:DBXPR06MB612;H:DBXPR06MB612.eurprd06.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:; Content-Type: text/plain; charset="us-ascii" Content-ID: <971629BB3547C04CAC69C99C7537D6C4@eurprd06.prod.outlook.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: visteon.com X-MS-Exchange-CrossTenant-originalarrivaltime: 31 May 2015 05:39:07.7215 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7a147aaf-01ec-498c-80a1-e34a8c63c548 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR06MB612 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Niranjan Dighe Replace kzalloc followed by memcpy by kmemdup. This patch was generated by 'make coccicheck' Signed-off-by: Niranjan Dighe --- 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