Commit b775d158 authored by Dan Carpenter's avatar Dan Carpenter Committed by Bjorn Andersson

rpmsg: glink: Fix memory leak in qcom_glink_alloc_intent()

We need to free "intent" and "intent->data" on a couple error paths.

Fixes: 933b45da ("rpmsg: glink: Add support for TX intents")
Acked-by: default avatarSricharan R <sricharan@codeaurora.org>
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 0a7480bd
...@@ -635,19 +635,18 @@ qcom_glink_alloc_intent(struct qcom_glink *glink, ...@@ -635,19 +635,18 @@ qcom_glink_alloc_intent(struct qcom_glink *glink,
unsigned long flags; unsigned long flags;
intent = kzalloc(sizeof(*intent), GFP_KERNEL); intent = kzalloc(sizeof(*intent), GFP_KERNEL);
if (!intent) if (!intent)
return NULL; return NULL;
intent->data = kzalloc(size, GFP_KERNEL); intent->data = kzalloc(size, GFP_KERNEL);
if (!intent->data) if (!intent->data)
return NULL; goto free_intent;
spin_lock_irqsave(&channel->intent_lock, flags); spin_lock_irqsave(&channel->intent_lock, flags);
ret = idr_alloc_cyclic(&channel->liids, intent, 1, -1, GFP_ATOMIC); ret = idr_alloc_cyclic(&channel->liids, intent, 1, -1, GFP_ATOMIC);
if (ret < 0) { if (ret < 0) {
spin_unlock_irqrestore(&channel->intent_lock, flags); spin_unlock_irqrestore(&channel->intent_lock, flags);
return NULL; goto free_data;
} }
spin_unlock_irqrestore(&channel->intent_lock, flags); spin_unlock_irqrestore(&channel->intent_lock, flags);
...@@ -656,6 +655,12 @@ qcom_glink_alloc_intent(struct qcom_glink *glink, ...@@ -656,6 +655,12 @@ qcom_glink_alloc_intent(struct qcom_glink *glink,
intent->reuse = reuseable; intent->reuse = reuseable;
return intent; return intent;
free_data:
kfree(intent->data);
free_intent:
kfree(intent);
return NULL;
} }
static void qcom_glink_handle_rx_done(struct qcom_glink *glink, static void qcom_glink_handle_rx_done(struct qcom_glink *glink,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment