lkml.org 
[lkml]   [2017]   [Sep]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] rpmsg: glink: fix memory leak
Date
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
\
 
 \ /
  Last update: 2017-09-17 14:15    [W:0.027 / U:8.632 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site