mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Olaf Hering <olaf@aepfle.de>
To: kys@microsoft.com, haiyangz@microsoft.com, gregkh@linuxfoundation.org
Cc: linux-kernel@vger.kernel.org, devel@linuxdriverproject.org,
	Olaf Hering <olaf@aepfle.de>
Subject: [PATCH 5/5] Drivers: hv: utils: use memdup_user in hvt_op_write
Date: Mon,  5 Oct 2015 15:27:19 +0000	[thread overview]
Message-ID: <1444058839-19008-6-git-send-email-olaf@aepfle.de> (raw)
In-Reply-To: <1444058839-19008-1-git-send-email-olaf@aepfle.de>

Use memdup_user to handle OOM.

Fixes: 14b50f80c32d ('Drivers: hv: util: introduce hv_utils_transport abstraction')

Signed-off-by: Olaf Hering <olaf@aepfle.de>
---
 drivers/hv/hv_utils_transport.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c
index 1505ee6..24b2766 100644
--- a/drivers/hv/hv_utils_transport.c
+++ b/drivers/hv/hv_utils_transport.c
@@ -80,11 +80,10 @@ static ssize_t hvt_op_write(struct file *file, const char __user *buf,
 
 	hvt = container_of(file->f_op, struct hvutil_transport, fops);
 
-	inmsg = kzalloc(count, GFP_KERNEL);
-	if (copy_from_user(inmsg, buf, count)) {
-		kfree(inmsg);
-		return -EFAULT;
-	}
+	inmsg = memdup_user(buf, count);
+	if (IS_ERR(inmsg))
+		return PTR_ERR(inmsg);
+
 	if (hvt->on_msg(inmsg, count))
 		return -EFAULT;
 	kfree(inmsg);

      parent reply	other threads:[~2015-10-05 15:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-05 15:27 [PATCH 0/5] various hyperv fixes Olaf Hering
2015-10-05 15:27 ` [PATCH 1/5] Drivers: hv: utils: run polling callback always in interrupt context Olaf Hering
2015-10-05 15:27 ` [PATCH 2/5] tools: hv: report ENOSPC errors in hv_fcopy_daemon Olaf Hering
2015-10-05 15:27 ` [PATCH 3/5] tools: hv: remove repeated HV_FCOPY string Olaf Hering
2015-10-05 15:27 ` [PATCH 4/5] Drivers: hv: util: catch allocation errors Olaf Hering
2015-10-05 15:27 ` Olaf Hering [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=1444058839-19008-6-git-send-email-olaf@aepfle.de \
    --to=olaf@aepfle.de \
    --cc=devel@linuxdriverproject.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®