From: Al Viro <viro@zeniv.linux.org.uk>
To: Zou Wei <zou_wei@huawei.com>
Cc: davem@davemloft.net, linux-ide@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next] ide: Use memdup_user() as a cleanup
Date: Wed, 22 Apr 2020 03:58:40 +0100 [thread overview]
Message-ID: <20200422025840.GJ23230@ZenIV.linux.org.uk> (raw)
In-Reply-To: <1587524381-120136-1-git-send-email-zou_wei@huawei.com>
On Wed, Apr 22, 2020 at 10:59:41AM +0800, Zou Wei wrote:
> if (taskout) {
> int outtotal = tasksize;
> - outbuf = kzalloc(taskout, GFP_KERNEL);
> - if (outbuf == NULL) {
> - err = -ENOMEM;
> - goto abort;
> - }
> - if (copy_from_user(outbuf, buf + outtotal, taskout)) {
> - err = -EFAULT;
> - goto abort;
> - }
> + outbuf = memdup_user(buf + outtotal, taskout);
> + if (IS_ERR(outbuf))
> + return PTR_ERR(outbuf);
> }
>
> if (taskin) {
> int intotal = tasksize + taskout;
> - inbuf = kzalloc(taskin, GFP_KERNEL);
> - if (inbuf == NULL) {
> - err = -ENOMEM;
> - goto abort;
> - }
> - if (copy_from_user(inbuf, buf + intotal, taskin)) {
> - err = -EFAULT;
> - goto abort;
> - }
> + inbuf = memdup_user(buf + intotal, taskin);
> + if (IS_ERR(inbuf))
> + return PTR_ERR(inbuf);
That smells like a leak - what happens if both taskin and taskout are
non-zero at the same time? <looks> actually, both parts are leaking -
there's
req_task = memdup_user(buf, tasksize);
if (IS_ERR(req_task))
return PTR_ERR(req_task);
shortly prior to that, so both of your failure exits are leaking.
prev parent reply other threads:[~2020-04-22 2:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-22 2:59 [PATCH -next] ide: Use memdup_user() as a cleanup Zou Wei
2020-04-22 2:58 ` Al Viro [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=20200422025840.GJ23230@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=davem@davemloft.net \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=zou_wei@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).