From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932381AbbE3KiA (ORCPT ); Sat, 30 May 2015 06:38:00 -0400 Received: from mail-am1on0106.outbound.protection.outlook.com ([157.56.112.106]:34542 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750855AbbE3Khu convert rfc822-to-8bit (ORCPT ); Sat, 30 May 2015 06:37:50 -0400 X-Greylist: delayed 464 seconds by postgrey-1.27 at vger.kernel.org; Sat, 30 May 2015 06:37:50 EDT From: "Dighe, Niranjan (N.)" 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" Subject: [PATCH] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup Thread-Topic: [PATCH] Staging: lustre: Replace kzalloc followed by memcpy with kmemdup Thread-Index: AQHQmsKBIzrqmBhXhEawEL5KegZYMA== Date: Sat, 30 May 2015 10:22:17 +0000 Message-ID: <20150530102211.GA12727@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:DBXPR06MB611; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(5005006)(520003)(3002001);SRVR:DBXPR06MB611;BCL:0;PCL:0;RULEID:;SRVR:DBXPR06MB611; x-forefront-prvs: 0592A9FDE6 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(199003)(68736005)(54356999)(77156002)(40100003)(62966003)(64706001)(122556002)(66066001)(33656002)(2656002)(33716001)(2900100001)(87936001)(102836002)(19580395003)(19580405001)(101416001)(2501003)(2860100001)(50986999)(105586002)(46102003)(2201001)(229853001)(106116001)(5002640100001)(106356001)(107886002)(5001830100001)(86362001)(97736004)(4001540100001)(189998001)(5001860100001)(5001770100001)(81156007)(5001960100002)(92566002)(13693001)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:DBXPR06MB611;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: <8F8F41B08C6C654E8EBD3EE820FF9D44@eurprd06.prod.outlook.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: visteon.com X-MS-Exchange-CrossTenant-originalarrivaltime: 30 May 2015 10:22:17.3135 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7a147aaf-01ec-498c-80a1-e34a8c63c548 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBXPR06MB611 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace kzalloc followed by memcpy by kmemdup. This patch was generated by 'make coccicheck' Signed-off-by: Niranjan Dighe 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