Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964938AbbLHMMb (ORCPT ); Tue, 8 Dec 2015 07:12:31 -0500 Received: from mail-db3on0121.outbound.protection.outlook.com ([157.55.234.121]:47388 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932607AbbLHMM3 convert rfc822-to-8bit (ORCPT ); Tue, 8 Dec 2015 07:12:29 -0500 X-Greylist: delayed 1108 seconds by postgrey-1.27 at vger.kernel.org; Tue, 08 Dec 2015 07:12:29 EST From: "Pathak, Rahul (R.)" To: "gregkh@linuxfoundation.org" , "stern@rowland.harvard.edu" , "kborer@gmail.com" , "dan.carpenter@oracle.com" , "chasemetzger15@gmail.com" CC: "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: [PATCH] usb: Use memdup_user to reuse the code Thread-Topic: [PATCH] usb: Use memdup_user to reuse the code Thread-Index: AQHRMa0HoDLQ9UL+LkC4bJuJixmjFA== Date: Tue, 8 Dec 2015 11:38:59 +0000 Message-ID: <20151208113851.GA12837@visteon.com> 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=rpathak@visteon.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [202.0.77.197] x-microsoft-exchange-diagnostics: 1;DB4PR06MB585;5:/VOL6xn0mTGqcvA9Xlyw/oDnpaRzKLEB06eXcx2BZBw4dQBtDlHDZAgka7STwk3PAMZA1vQMFFWPLiyYSVPUAE2OVTYqnukzPNwqpx1EFFuOvhUAKZUYTTH77lILhpeOOrmHkXlINl/62vKlws6jYw==;24:M8OROREVyXW0Xz1oFI4vVb4wDj0owr0DEy3MyU6a1QANkuvO8TX184DnhHB66oFohtMAwJr4wVshzmIut00TBW2u9Lr1zOEkTXd4hWVtKXg= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB4PR06MB585; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(208512329853888); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(5005006)(8121501046)(3002001)(10201501046);SRVR:DB4PR06MB585;BCL:0;PCL:0;RULEID:;SRVR:DB4PR06MB585; x-forefront-prvs: 0784C803FD x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(189002)(199003)(10400500002)(40100003)(1220700001)(5002640100001)(102836003)(11100500001)(81156007)(5001960100002)(2900100001)(97736004)(229853001)(92566002)(122556002)(2171001)(5008740100001)(5001770100001)(101416001)(86362001)(189998001)(50986999)(1096002)(33656002)(2501003)(66066001)(106356001)(105586002)(2201001)(87936001)(19580395003)(19580405001)(1076002)(54356999)(586003)(106116001)(36756003)(6116002)(5004730100002)(77096005)(3846002);DIR:OUT;SFP:1102;SCL:1;SRVR:DB4PR06MB585;H:DB4PR06MB585.eurprd06.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: visteon.com X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Dec 2015 11:38:59.3078 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7a147aaf-01ec-498c-80a1-e34a8c63c548 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR06MB585 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1382 Lines: 38 From: Rahul Pathak Fixing coccicheck warning which recommends to use memdup_user instead to reimplement its code, using memdup_user simplifies the code ./drivers/usb/core/devio.c:1398:11-18: WARNING opportunity for memdup_user Signed-off-by: Rahul Pathak --- drivers/usb/core/devio.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 38ae877c..05266f0 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c @@ -1395,11 +1395,9 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb number_of_packets = uurb->number_of_packets; isofrmlen = sizeof(struct usbdevfs_iso_packet_desc) * number_of_packets; - isopkt = kmalloc(isofrmlen, GFP_KERNEL); - if (!isopkt) - return -ENOMEM; - if (copy_from_user(isopkt, iso_frame_desc, isofrmlen)) { - ret = -EFAULT; + isopkt = memdup_user(iso_frame_desc, isofrmlen); + if (IS_ERR(isopkt)) { + ret = PTR_ERR(isopkt); goto error; } for (totlen = u = 0; u < number_of_packets; u++) { -- 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/