Skip to contentSkip to conversation

rpmsg: glink: fix memory leak

PATCH New Sudip Mukherjee 1 participant 1 message Sep 17, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rpmsg: glink: fix memory leak

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

---
 drivers/rpmsg/qcom_glink_native.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/rpmsg/qcom_glink_native.c +5 -1
index 5a5e927..2e64c4d 100644
@@ -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);
Signature · 1 line
2.7.4