From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932202AbbCaPKp (ORCPT ); Tue, 31 Mar 2015 11:10:45 -0400 Received: from mail-db3on0140.outbound.protection.outlook.com ([157.55.234.140]:14506 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754630AbbCaPKh convert rfc822-to-8bit (ORCPT ); Tue, 31 Mar 2015 11:10:37 -0400 X-Greylist: delayed 85422 seconds by postgrey-1.27 at vger.kernel.org; Tue, 31 Mar 2015 11:10:36 EDT From: "Dhere, Chaitanya (C.)" To: "oleg.drokin@intel.com" , "andreas.dilger@intel.com" , "gregkh@linuxfoundation.org" , "viro@zeniv.linux.org.uk" , "jinshan.xiong@intel.com" , "aybuke.147@gmail.com" , "john.hammond@intel.com" , "Julia.Lawall@lip6.fr" CC: "HPDD-discuss@lists.01.org" , "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] staging: lustre: replace kzalloc with copy_from_user with memdup_user Thread-Topic: [PATCH] staging: lustre: replace kzalloc with copy_from_user with memdup_user Thread-Index: AQHQa8TVGJHC+muUcEiw8TW66xYZ+g== Date: Tue, 31 Mar 2015 15:10:33 +0000 Message-ID: <20150331150933.GA2833@chaitanya-Ideapad-Z560> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [117.195.26.104] authentication-results: intel.com; dkim=none (message not signed) header.d=none; x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB3PR06MB027; x-microsoft-antispam-prvs: x-forefront-antispam-report: BMV:1;SFV:NSPM;SFS:(10019020)(6009001)(87936001)(2860100001)(46102003)(19580405001)(229853001)(33656002)(40100003)(62966003)(2501003)(2656002)(33716001)(19580395003)(54356999)(66066001)(50986999)(102836002)(92566002)(2900100001)(86362001)(77156002)(122556002)(106116001)(13693001);DIR:OUT;SFP:1102;SCL:1;SRVR:DB3PR06MB027;H:DB3PR06MB028.eurprd06.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(5005006)(5002010);SRVR:DB3PR06MB027;BCL:0;PCL:0;RULEID:;SRVR:DB3PR06MB027; x-forefront-prvs: 0532BF6DC2 Content-Type: text/plain; charset="us-ascii" Content-ID: <8DB029B759061A4C839EDBFEB1230A6D@eurprd06.prod.outlook.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: visteon.com X-MS-Exchange-CrossTenant-originalarrivaltime: 31 Mar 2015 15:10:33.3984 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7a147aaf-01ec-498c-80a1-e34a8c63c548 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR06MB027 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch replaces kzalloc and copy_from_user with memdup_user call This change was detected with coccinelle tool Signed-off-by: Chaitanya Dhere --- drivers/staging/lustre/lustre/llite/file.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 85e74d1..85b5567 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2368,14 +2368,9 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) struct hsm_state_set *hss; int rc; - hss = kzalloc(sizeof(*hss), GFP_NOFS); - if (!hss) - return -ENOMEM; - - if (copy_from_user(hss, (char *)arg, sizeof(*hss))) { - OBD_FREE_PTR(hss); - return -EFAULT; - } + hss = memdup_user((char *)arg, sizeof(*hss)); + if (IS_ERR(hss)) + return PTR_ERR(hss); rc = ll_hsm_state_set(inode, hss); -- 1.7.9.5