mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] rpmsg: glink: fix memory leak
@ 2017-09-17 12:14 Sudip Mukherjee
  0 siblings, 0 replies; only message in thread
From: Sudip Mukherjee @ 2017-09-17 12:14 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Bjorn Andersson
  Cc: linux-kernel, linux-remoteproc, Sudip Mukherjee

We missed freeing intent and intent->data on error conditions.

Signed-off-by: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
---
 drivers/rpmsg/qcom_glink_native.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index 5a5e927..2e64c4d 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -640,13 +640,17 @@ qcom_glink_alloc_intent(struct qcom_glink *glink,
 		return NULL;
 
 	intent->data = kzalloc(size, GFP_KERNEL);
-	if (!intent->data)
+	if (!intent->data) {
+		kfree(intent);
 		return NULL;
+	}
 
 	spin_lock_irqsave(&channel->intent_lock, flags);
 	ret = idr_alloc_cyclic(&channel->liids, intent, 1, -1, GFP_ATOMIC);
 	if (ret < 0) {
 		spin_unlock_irqrestore(&channel->intent_lock, flags);
+		kfree(intent->data);
+		kfree(intent);
 		return NULL;
 	}
 	spin_unlock_irqrestore(&channel->intent_lock, flags);
-- 
2.7.4

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-09-17 12:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-17 12:14 [PATCH] rpmsg: glink: fix memory leak Sudip Mukherjee

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®