From: Dan Carpenter <dan.carpenter@oracle.com>
To: "Pathak, Rahul (R.)" <rpathak@visteon.com>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"stern@rowland.harvard.edu" <stern@rowland.harvard.edu>,
"kborer@gmail.com" <kborer@gmail.com>,
"chasemetzger15@gmail.com" <chasemetzger15@gmail.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: Use memdup_user to reuse the code
Date: Tue, 8 Dec 2015 14:51:57 +0300 [thread overview]
Message-ID: <20151208115157.GN7289@mwanda> (raw)
In-Reply-To: <20151208113851.GA12837@visteon.com>
On Tue, Dec 08, 2015 at 11:38:59AM +0000, Pathak, Rahul (R.) wrote:
> 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;
This introduces a one err bug.
https://plus.google.com/106378716002406849458/posts/dnanfhQ4mHQ
We can't call kfree(isopkt) when it is an ERR_PTR.
Set it to NULL:
isopkt = memdup_user(iso_frame_desc, isofrmlen);
if (IS_ERR(isopkt)) {
ret = PTR_ERR(isopkt);
isopkt = NULL;
goto error;
}
regards,
dan carpenter
prev parent reply other threads:[~2015-12-08 11:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-08 11:38 [PATCH] usb: Use memdup_user to reuse the code Pathak, Rahul (R.)
2015-12-08 11:51 ` Dan Carpenter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151208115157.GN7289@mwanda \
--to=dan.carpenter@oracle.com \
--cc=chasemetzger15@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=kborer@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=rpathak@visteon.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox