Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965179AbbLHPXN (ORCPT ); Tue, 8 Dec 2015 10:23:13 -0500 Received: from iolanthe.rowland.org ([192.131.102.54]:50694 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S965112AbbLHPXI (ORCPT ); Tue, 8 Dec 2015 10:23:08 -0500 Date: Tue, 8 Dec 2015 10:23:07 -0500 (EST) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: "Pathak, Rahul (R.)" cc: "gregkh@linuxfoundation.org" , "kborer@gmail.com" , "dan.carpenter@oracle.com" , "chasemetzger15@gmail.com" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] usb: Use memdup_user to reuse the code In-Reply-To: <20151208122358.GA17073@visteon.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1837 Lines: 52 On Tue, 8 Dec 2015, Pathak, Rahul (R.) 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 > > Changes after v1: setting isopkt=NULL for proper kfree() call This line belongs below the "---" tear line, so that it doesn't show up in the final commit changelog. People reading the final commit won't care about earlier versions of the patch. > Signed-off-by: Rahul Pathak > --- > 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++) { Aside from that, Acked-by: Alan Stern Alan Stern -- 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/