mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: devel@linuxdriverproject.org
Cc: "K. Y. Srinivasan" <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	linux-kernel@vger.kernel.org, Olaf Hering <olaf@aepfle.de>
Subject: [PATCH 1/4] Drivers: hv: utils: fix memory leak on on_msg() failure
Date: Thu, 12 Nov 2015 12:32:13 +0100	[thread overview]
Message-ID: <1447327936-26035-2-git-send-email-vkuznets@redhat.com> (raw)
In-Reply-To: <1447327936-26035-1-git-send-email-vkuznets@redhat.com>

inmsg should be freed in case of on_msg() failure to avoid memory leak.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 drivers/hv/hv_utils_transport.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/hv/hv_utils_transport.c b/drivers/hv/hv_utils_transport.c
index 24b2766..1d20451 100644
--- a/drivers/hv/hv_utils_transport.c
+++ b/drivers/hv/hv_utils_transport.c
@@ -77,6 +77,7 @@ static ssize_t hvt_op_write(struct file *file, const char __user *buf,
 {
 	struct hvutil_transport *hvt;
 	u8 *inmsg;
+	ssize_t ret = count;
 
 	hvt = container_of(file->f_op, struct hvutil_transport, fops);
 
@@ -85,10 +86,10 @@ static ssize_t hvt_op_write(struct file *file, const char __user *buf,
 		return PTR_ERR(inmsg);
 
 	if (hvt->on_msg(inmsg, count))
-		return -EFAULT;
+		ret = -EFAULT;
 	kfree(inmsg);
 
-	return count;
+	return ret;
 }
 
 static unsigned int hvt_op_poll(struct file *file, poll_table *wait)
-- 
2.4.3


  reply	other threads:[~2015-11-12 11:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12 11:32 [PATCH 0/4] Drivers: hv: utils: prevent crash when a utility driver is disabled host side Vitaly Kuznetsov
2015-11-12 11:32 ` Vitaly Kuznetsov [this message]
2015-11-16 15:54   ` [PATCH 1/4] Drivers: hv: utils: fix memory leak on on_msg() failure Dan Carpenter
2015-11-16 17:40     ` Vitaly Kuznetsov
2015-11-12 11:32 ` [PATCH 2/4] Drivers: hv: utils: rename outmsg_lock Vitaly Kuznetsov
2015-11-12 11:32 ` [PATCH 3/4] Drivers: hv: utils: introduce HVUTIL_TRANSPORT_DESTROY mode Vitaly Kuznetsov
2015-11-12 11:32 ` [PATCH 4/4] Drivers: hv: utils: fix crash when device is removed from host side Vitaly Kuznetsov

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=1447327936-26035-2-git-send-email-vkuznets@redhat.com \
    --to=vkuznets@redhat.com \
    --cc=devel@linuxdriverproject.org \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olaf@aepfle.de \
    /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

Powered by JetHome