Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756153AbbFPHF3 (ORCPT ); Tue, 16 Jun 2015 03:05:29 -0400 Received: from mail-db3on0124.outbound.protection.outlook.com ([157.55.234.124]:20200 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753890AbbFPHFU convert rfc822-to-8bit (ORCPT ); Tue, 16 Jun 2015 03:05:20 -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: AQHQqALM4s2sGjaNh0qgoa8uSbxixw== Date: Tue, 16 Jun 2015 07:05:17 +0000 Message-ID: <1434438239-4896-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:Anq6d+NwsaBLMtDhvWnXC/VWuTcFLiqW5lK2TS1J2eSs6QPAbI6Accwou1hhFX3kOwBPoKvoEZT5I1hWREWoUXmOfyNQyI3cSYvwwo20paTvQdqBk6xzz/di2w/9mXzFTmnd5lQDTs+uWyTLbO4Ffg==;10:ETxFkho4NuNQoflg8SQfdAY0LFO6Qfh6XDMkM30Rc40vManl0JTytmlJm6I1zuyYxxpbl3jviIVY4AUgaQgBxd9ipFe10f1IfI3hO3zh32A=;6:3OzVzz/RJMf5rXcloZVn7bqWE4CSLTqZxjAU6uGwULWS4CtXKP0zaS16x7Zq2/k7 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:05:17.0971 (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: 2196 Lines: 73 From: Abdul Hussain This patch uses memdup_user rather than duplicating its implementation Signed-off-by: Abdul Hussain --- drivers/staging/lustre/lustre/llite/dir.c | 32 +++++++++---------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c index c2eb4f2..3d746a9 100644 --- a/drivers/staging/lustre/lustre/llite/dir.c +++ b/drivers/staging/lustre/lustre/llite/dir.c @@ -1747,15 +1747,9 @@ out_quotactl: struct hsm_user_request *hur; ssize_t totalsize; - hur = kzalloc(sizeof(*hur), GFP_NOFS); - if (!hur) - return -ENOMEM; - - /* We don't know the true size yet; copy the fixed-size part */ - if (copy_from_user(hur, (void *)arg, sizeof(*hur))) { - kfree(hur); - return -EFAULT; - } + hur = memdup_user((void *)arg, sizeof(*hur)); + if (IS_ERR(hur)) + return PTR_ERR(hur); /* Compute the whole struct size */ totalsize = hur_len(hur); @@ -1833,13 +1827,9 @@ out_quotactl: struct hsm_copy *copy; int rc; - copy = kzalloc(sizeof(*copy), GFP_NOFS); - if (!copy) - return -ENOMEM; - if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { - kfree(copy); - return -EFAULT; - } + copy = memdup_user((char *)arg, sizeof(*copy)); + if (IS_ERR(copy)) + return PTR_ERR(copy); rc = ll_ioc_copy_start(inode->i_sb, copy); if (copy_to_user((char *)arg, copy, sizeof(*copy))) @@ -1852,13 +1842,9 @@ out_quotactl: struct hsm_copy *copy; int rc; - copy = kzalloc(sizeof(*copy), GFP_NOFS); - if (!copy) - return -ENOMEM; - if (copy_from_user(copy, (char *)arg, sizeof(*copy))) { - kfree(copy); - return -EFAULT; - } + copy = memdup_user((char *)arg, sizeof(*copy)); + if (IS_ERR(copy)) + return PTR_ERR(copy); rc = ll_ioc_copy_end(inode->i_sb, copy); if (copy_to_user((char *)arg, copy, sizeof(*copy))) -- 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/