mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Colin King <colin.king@canonical.com>
To: David Kershner <david.kershner@unisys.com>, sparmaintainer@unisys.com
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] drivers: visorbus: fix memory leak on parser_ctx
Date: Thu, 11 Oct 2018 16:35:22 +0100	[thread overview]
Message-ID: <20181011153522.26237-1-colin.king@canonical.com> (raw)

From: Colin Ian King <colin.king@canonical.com>

Currently when the call to visorchannel_signalinsert fails the error
return path does not free parser_ctx.  Fix this by kfree'ing it on
the error return path.

Detected by CoverityScan, CID#1451916 ("Resource leak")

Fixes: a35e3268da51 ("staging: unisys: visorchipset: remove local_addr in handle_command")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/visorbus/visorchipset.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/visorbus/visorchipset.c b/drivers/visorbus/visorchipset.c
index ca752b8f495f..09d1536edfb1 100644
--- a/drivers/visorbus/visorchipset.c
+++ b/drivers/visorbus/visorchipset.c
@@ -1383,8 +1383,10 @@ static int handle_command(struct controlvm_message inmsg, u64 channel_addr)
 	controlvm_init_response(&ackmsg, &inmsg.hdr, CONTROLVM_RESP_SUCCESS);
 	err = visorchannel_signalinsert(chipset_dev->controlvm_channel,
 					CONTROLVM_QUEUE_ACK, &ackmsg);
-	if (err)
+	if (err) {
+		kfree(parser_ctx);
 		return err;
+	}
 	switch (inmsg.hdr.id) {
 	case CONTROLVM_CHIPSET_INIT:
 		err = chipset_init(&inmsg);
-- 
2.17.1


                 reply	other threads:[~2018-10-11 15:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20181011153522.26237-1-colin.king@canonical.com \
    --to=colin.king@canonical.com \
    --cc=david.kershner@unisys.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sparmaintainer@unisys.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

all inboxes | Powered by JetHome®