Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755993AbbFPHFB (ORCPT ); Tue, 16 Jun 2015 03:05:01 -0400 Received: from mail-db3on0130.outbound.protection.outlook.com ([157.55.234.130]:63883 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752492AbbFPHEy convert rfc822-to-8bit (ORCPT ); Tue, 16 Jun 2015 03:04:54 -0400 From: "Abdul, Hussain (H.)" To: "gregkh@linuxfoundation.org" CC: "oleg.drokin@intel.com" , "andreas.dilger@intel.com" , "HPDD-discuss@lists.01.org" , "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" , "Ravindran, Madhusudhanan (M.)" , "Dighe, Niranjan (N.)" Subject: [PATCH] Staging: lustre: Use memdup_user rather than duplicating its implementation Thread-Topic: [PATCH] Staging: lustre: Use memdup_user rather than duplicating its implementation Thread-Index: AQHQqAK9ebQ92OQcaUmRBlefDCpJeA== Date: Tue, 16 Jun 2015 07:04:51 +0000 Message-ID: <1434438213-4792-1-git-send-email-habdul@visteon.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 1.9.1 authentication-results: linuxfoundation.org; dkim=none (message not signed) header.d=none; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [74.112.167.117] x-microsoft-exchange-diagnostics: 1;DB5PR06MB1110;3:CpTHBVKDFnS+h8wcCFxgJQQStdeDYpS20MN+hBEea1fYD2CFgSK7OpEFmlk5kge5nNXUlfPu250gzxHVwkBuPW5VYbETQ7krKG7+zerAp6Kk6X6BquiYYUG6ZCQ26G7zJp1g/5XqD1lEQS5YEDq63g==;10:i6IZm6+tggWCohki9ed9zBkeVCFdtOBbkNloRdM9bIeZTVlttrOuPY4P7Sgd408lEgT4xF7iiDI57LgR3YctN6+vlnfkQFouOlZRo+vdDxg=;6:sGKRvA80dLrmawT+ZuR3oCtjQkgjzqD+hGrJpnTL9PAlvFU1NycJATwsHIu1JRka x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR06MB1110; 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:DB5PR06MB1110;BCL:0;PCL:0;RULEID:;SRVR:DB5PR06MB1110; x-forefront-prvs: 06098A2863 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(2501003)(229853001)(2351001)(2656002)(87936001)(33646002)(19580395003)(19580405001)(46102003)(86362001)(106116001)(36756003)(189998001)(50986999)(40100003)(2900100001)(77096005)(102836002)(50226001)(62966003)(5002640100001)(77156002)(107886002)(92566002)(5001960100002)(110136002)(66066001)(122556002)(4001430100001);DIR:OUT;SFP:1102;SCL:1;SRVR:DB5PR06MB1110;H:DB5PR06MB1112.eurprd06.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT MIME-Version: 1.0 X-OriginatorOrg: visteon.com X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Jun 2015 07:04:51.4710 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7a147aaf-01ec-498c-80a1-e34a8c63c548 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR06MB1110 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1694 Lines: 56 From: Abdul Hussain This patch uses memdup_user rather than duplicating its implementation Signed-off-by: Abdul Hussain --- drivers/staging/lustre/lustre/llite/file.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 4f9b1c7..3075db2 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -2361,14 +2361,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))) { - kfree(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); @@ -2488,14 +2483,9 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg) case LL_IOC_HSM_IMPORT: { struct hsm_user_import *hui; - hui = kzalloc(sizeof(*hui), GFP_NOFS); - if (!hui) - return -ENOMEM; - - if (copy_from_user(hui, (void *)arg, sizeof(*hui))) { - kfree(hui); - return -EFAULT; - } + hui = memdup_user((void *)arg, sizeof(*hui)); + if (IS_ERR(hui)) + return PTR_ERR(hui); rc = ll_hsm_import(inode, file, hui); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/