Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754303AbbL3JQE (ORCPT ); Wed, 30 Dec 2015 04:16:04 -0500 Received: from mail-db3on0129.outbound.protection.outlook.com ([157.55.234.129]:2271 "EHLO emea01-db3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752034AbbL3JP6 convert rfc822-to-8bit (ORCPT ); Wed, 30 Dec 2015 04:15:58 -0500 From: "Pathak, Rahul (R.)" To: "gregkh@linuxfoundation.org" , "stern@rowland.harvard.edu" , "kborer@gmail.com" , "chasemetzger15@gmail.com" , "dan.carpenter@oracle.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 RESEND] usb: Use memdup_user to reuse the code Thread-Topic: [PATCH v2 RESEND] usb: Use memdup_user to reuse the code Thread-Index: AQHRM9Z+ZlP5Km4p0U2MN4jbpeUJ8p7jXaUA Date: Wed, 30 Dec 2015 09:15:55 +0000 Message-ID: <20151230091544.GA17620@visteon.com> References: <20151211054033.GA4952@visteon.com> In-Reply-To: <20151211054033.GA4952@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;DB4PR06MB587;5:cxhnhaNBPeqOCzPt1Cia4Mof6ez/WLofm/Qg/fRR1NXnXLQ9nbtbLoprqnxudvcQ7lL2C1Vpzto9vEGeP+JFtW7JNxAAX6Q8Xw4eFPcg+2Au+xC3DR68uQWvs919GiEM2kYD5NzjeTCqjQJxXFz84w==;24:HQSahW+0YkIUAQNN/o1ZdLUQeJo0QsOuf21K2RmW4FXZqhsQ8IVR+2Y/LneUFge82q87P4oQVWzwpQFwvsA1HGQjU2uY0PQRRsW9E1IqhGc= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB4PR06MB587; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(208512329853888); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(520078)(5005006)(3002001)(10201501046);SRVR:DB4PR06MB587;BCL:0;PCL:0;RULEID:;SRVR:DB4PR06MB587; x-forefront-prvs: 08062C429B x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(24454002)(199003)(189002)(11100500001)(189998001)(1220700001)(19580405001)(50986999)(1076002)(54356999)(6116002)(2201001)(5008740100001)(87936001)(2171001)(81156007)(2900100001)(105586002)(101416001)(106356001)(3846002)(86362001)(5001770100001)(33656002)(106116001)(5002640100001)(40100003)(1096002)(10400500002)(586003)(107886002)(5001960100002)(2501003)(97736004)(2950100001)(77096005)(19580395003)(76176999)(92566002)(102836003)(5004730100002)(36756003)(122556002)(66066001);DIR:OUT;SFP:1102;SCL:1;SRVR:DB4PR06MB587;H:DB4PR06MB585.eurprd06.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <8F24CB57E020FB4994EF14EAB1AFE750@eurprd06.prod.outlook.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: visteon.com X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Dec 2015 09:15:55.4113 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7a147aaf-01ec-498c-80a1-e34a8c63c548 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR06MB587 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1717 Lines: 52 Hello Greg, This patch is not yet merged, its already been reviewed and acked by Alan. Thanks Rahul On Thu, Dec 10, 2015 at 09:40:33PM -0800, Rahul Pathak wrote: > 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 > > --- > > Changes after v1: setting isopkt=NULL for proper kfree() call > > --- > drivers/usb/core/devio.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c > index 38ae877c..844407c 100644 > --- a/drivers/usb/core/devio.c > +++ b/drivers/usb/core/devio.c > @@ -1395,11 +1395,10 @@ 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); > + isopkt = NULL; > 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/