* [PATCH v2] usb: Use memdup_user to reuse the code
@ 2015-12-08 12:24 Pathak, Rahul (R.)
2015-12-08 15:23 ` Alan Stern
0 siblings, 1 reply; 6+ messages in thread
From: Pathak, Rahul (R.) @ 2015-12-08 12:24 UTC (permalink / raw)
To: gregkh, stern, kborer, dan.carpenter, chasemetzger15
Cc: linux-usb, linux-kernel
From: Rahul Pathak <rpathak@visteon.com>
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
Signed-off-by: Rahul Pathak <rpathak@visteon.com>
---
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] usb: Use memdup_user to reuse the code
2015-12-08 12:24 [PATCH v2] usb: Use memdup_user to reuse the code Pathak, Rahul (R.)
@ 2015-12-08 15:23 ` Alan Stern
2015-12-09 8:02 ` Pathak, Rahul (R.)
0 siblings, 1 reply; 6+ messages in thread
From: Alan Stern @ 2015-12-08 15:23 UTC (permalink / raw)
To: Pathak, Rahul (R.)
Cc: gregkh, kborer, dan.carpenter, chasemetzger15, linux-usb, linux-kernel
On Tue, 8 Dec 2015, Pathak, Rahul (R.) wrote:
> From: Rahul Pathak <rpathak@visteon.com>
>
> 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 <rpathak@visteon.com>
> ---
> 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 <stern@rowland.harvard.edu>
Alan Stern
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] usb: Use memdup_user to reuse the code
2015-12-08 15:23 ` Alan Stern
@ 2015-12-09 8:02 ` Pathak, Rahul (R.)
2015-12-09 14:28 ` gregkh
2015-12-11 16:31 ` gregkh
0 siblings, 2 replies; 6+ messages in thread
From: Pathak, Rahul (R.) @ 2015-12-09 8:02 UTC (permalink / raw)
To: Alan Stern
Cc: gregkh, kborer, dan.carpenter, chasemetzger15, linux-usb, linux-kernel
Hello Alan,
Should I resend this patch version with the tear line correction?
Regards
Rahul Pathak
________________________________________
From: Alan Stern <stern@rowland.harvard.edu>
Sent: Tuesday, December 8, 2015 8:53 PM
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
On Tue, 8 Dec 2015, Pathak, Rahul (R.) wrote:
> From: Rahul Pathak <rpathak@visteon.com>
>
> 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 <rpathak@visteon.com>
> ---
> 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 <stern@rowland.harvard.edu>
Alan Stern
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] usb: Use memdup_user to reuse the code
2015-12-09 8:02 ` Pathak, Rahul (R.)
@ 2015-12-09 14:28 ` gregkh
2015-12-11 16:31 ` gregkh
1 sibling, 0 replies; 6+ messages in thread
From: gregkh @ 2015-12-09 14:28 UTC (permalink / raw)
To: Pathak, Rahul (R.)
Cc: Alan Stern, kborer, dan.carpenter, chasemetzger15, linux-usb,
linux-kernel
On Wed, Dec 09, 2015 at 08:02:53AM +0000, Pathak, Rahul (R.) wrote:
> Hello Alan,
>
> Should I resend this patch version with the tear line correction?
Why wouldn't you?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] usb: Use memdup_user to reuse the code
2015-12-09 8:02 ` Pathak, Rahul (R.)
2015-12-09 14:28 ` gregkh
@ 2015-12-11 16:31 ` gregkh
2015-12-12 4:15 ` rahul pathak
1 sibling, 1 reply; 6+ messages in thread
From: gregkh @ 2015-12-11 16:31 UTC (permalink / raw)
To: Pathak, Rahul (R.)
Cc: Alan Stern, kborer, dan.carpenter, chasemetzger15, linux-usb,
linux-kernel
On Wed, Dec 09, 2015 at 08:02:53AM +0000, Pathak, Rahul (R.) wrote:
> Hello Alan,
>
> Should I resend this patch version with the tear line correction?
Yes please.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] usb: Use memdup_user to reuse the code
2015-12-11 16:31 ` gregkh
@ 2015-12-12 4:15 ` rahul pathak
0 siblings, 0 replies; 6+ messages in thread
From: rahul pathak @ 2015-12-12 4:15 UTC (permalink / raw)
To: gregkh
Cc: Pathak, Rahul (R.),
Alan Stern, kborer, dan.carpenter, chasemetzger15, linux-usb,
linux-kernel
Hello Greg,
I have already resent the patch yesterday in new mail.
-- Sending this mail again because previous mail was blocked as spam.
Regards
Rahul
On Fri, Dec 11, 2015 at 10:01 PM, gregkh@linuxfoundation.org
<gregkh@linuxfoundation.org> wrote:
> On Wed, Dec 09, 2015 at 08:02:53AM +0000, Pathak, Rahul (R.) wrote:
>> Hello Alan,
>>
>> Should I resend this patch version with the tear line correction?
>
> Yes please.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-12-12 4:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-08 12:24 [PATCH v2] usb: Use memdup_user to reuse the code Pathak, Rahul (R.)
2015-12-08 15:23 ` Alan Stern
2015-12-09 8:02 ` Pathak, Rahul (R.)
2015-12-09 14:28 ` gregkh
2015-12-11 16:31 ` gregkh
2015-12-12 4:15 ` rahul pathak
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.