public inbox for linux-remoteproc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] rpmsg: glink: Unlock on error in qcom_glink_request_intent()
@ 2017-09-08 10:33 Dan Carpenter
  2017-09-08 10:34 ` [PATCH 2/2] rpmsg: glink: Fix memory leak in qcom_glink_alloc_intent() Dan Carpenter
  2017-09-08 11:13 ` [PATCH 1/2] rpmsg: glink: Unlock on error in qcom_glink_request_intent() Sricharan R
  0 siblings, 2 replies; 4+ messages in thread
From: Dan Carpenter @ 2017-09-08 10:33 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Sricharan R
  Cc: Bjorn Andersson, linux-remoteproc, kernel-janitors

If qcom_glink_tx() fails, then we need to unlock before returning the
error code.

Fixes: 27b9c5b66b23 ("rpmsg: glink: Request for intents when unavailable")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index 5a5e927ea50f..fecb1dafa8f3 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -1197,7 +1197,7 @@ static int qcom_glink_request_intent(struct qcom_glink *glink,
 
 	ret = qcom_glink_tx(glink, &cmd, sizeof(cmd), NULL, 0, true);
 	if (ret)
-		return ret;
+		goto unlock;
 
 	ret = wait_for_completion_timeout(&channel->intent_req_comp, 10 * HZ);
 	if (!ret) {
@@ -1207,6 +1207,7 @@ static int qcom_glink_request_intent(struct qcom_glink *glink,
 		ret = channel->intent_req_result ? 0 : -ECANCELED;
 	}
 
+unlock:
 	mutex_unlock(&channel->intent_req_lock);
 	return ret;
 }

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] rpmsg: glink: Fix memory leak in qcom_glink_alloc_intent()
  2017-09-08 10:33 [PATCH 1/2] rpmsg: glink: Unlock on error in qcom_glink_request_intent() Dan Carpenter
@ 2017-09-08 10:34 ` Dan Carpenter
  2017-09-08 11:14   ` Sricharan R
  2017-09-08 11:13 ` [PATCH 1/2] rpmsg: glink: Unlock on error in qcom_glink_request_intent() Sricharan R
  1 sibling, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2017-09-08 10:34 UTC (permalink / raw)
  To: Ohad Ben-Cohen, Sricharan R
  Cc: Bjorn Andersson, linux-remoteproc, kernel-janitors

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

Fixes: 933b45da5d1d ("rpmsg: glink: Add support for TX intents")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
index fecb1dafa8f3..5dcc9bf1c5bc 100644
--- a/drivers/rpmsg/qcom_glink_native.c
+++ b/drivers/rpmsg/qcom_glink_native.c
@@ -635,19 +635,18 @@ qcom_glink_alloc_intent(struct qcom_glink *glink,
 	unsigned long flags;
 
 	intent = kzalloc(sizeof(*intent), GFP_KERNEL);
-
 	if (!intent)
 		return NULL;
 
 	intent->data = kzalloc(size, GFP_KERNEL);
 	if (!intent->data)
-		return NULL;
+		goto free_intent;
 
 	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);
-		return NULL;
+		goto free_data;
 	}
 	spin_unlock_irqrestore(&channel->intent_lock, flags);
 
@@ -656,6 +655,12 @@ qcom_glink_alloc_intent(struct qcom_glink *glink,
 	intent->reuse = reuseable;
 
 	return intent;
+
+free_data:
+	kfree(intent->data);
+free_intent:
+	kfree(intent);
+	return NULL;
 }
 
 static void qcom_glink_handle_rx_done(struct qcom_glink *glink,

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] rpmsg: glink: Unlock on error in qcom_glink_request_intent()
  2017-09-08 10:33 [PATCH 1/2] rpmsg: glink: Unlock on error in qcom_glink_request_intent() Dan Carpenter
  2017-09-08 10:34 ` [PATCH 2/2] rpmsg: glink: Fix memory leak in qcom_glink_alloc_intent() Dan Carpenter
@ 2017-09-08 11:13 ` Sricharan R
  1 sibling, 0 replies; 4+ messages in thread
From: Sricharan R @ 2017-09-08 11:13 UTC (permalink / raw)
  To: Dan Carpenter, Ohad Ben-Cohen
  Cc: Bjorn Andersson, linux-remoteproc, kernel-janitors

Hi,

On 9/8/2017 4:03 PM, Dan Carpenter wrote:
> If qcom_glink_tx() fails, then we need to unlock before returning the
> error code.
> 
> Fixes: 27b9c5b66b23 ("rpmsg: glink: Request for intents when unavailable")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
> index 5a5e927ea50f..fecb1dafa8f3 100644
> --- a/drivers/rpmsg/qcom_glink_native.c
> +++ b/drivers/rpmsg/qcom_glink_native.c
> @@ -1197,7 +1197,7 @@ static int qcom_glink_request_intent(struct qcom_glink *glink,
>  
>  	ret = qcom_glink_tx(glink, &cmd, sizeof(cmd), NULL, 0, true);
>  	if (ret)
> -		return ret;
> +		goto unlock;
>  
>  	ret = wait_for_completion_timeout(&channel->intent_req_comp, 10 * HZ);
>  	if (!ret) {
> @@ -1207,6 +1207,7 @@ static int qcom_glink_request_intent(struct qcom_glink *glink,
>  		ret = channel->intent_req_result ? 0 : -ECANCELED;
>  	}
>  
> +unlock:

Thanks for the catch.

Acked-by: Sricharan R <sricharan@codeaurora.org>

Regards,
 Sricharan

-- 
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] rpmsg: glink: Fix memory leak in qcom_glink_alloc_intent()
  2017-09-08 10:34 ` [PATCH 2/2] rpmsg: glink: Fix memory leak in qcom_glink_alloc_intent() Dan Carpenter
@ 2017-09-08 11:14   ` Sricharan R
  0 siblings, 0 replies; 4+ messages in thread
From: Sricharan R @ 2017-09-08 11:14 UTC (permalink / raw)
  To: Dan Carpenter, Ohad Ben-Cohen
  Cc: Bjorn Andersson, linux-remoteproc, kernel-janitors

Hi,

On 9/8/2017 4:04 PM, Dan Carpenter wrote:
> We need to free "intent" and "intent->data" on a couple error paths.
> 
> Fixes: 933b45da5d1d ("rpmsg: glink: Add support for TX intents")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c
> index fecb1dafa8f3..5dcc9bf1c5bc 100644
> --- a/drivers/rpmsg/qcom_glink_native.c
> +++ b/drivers/rpmsg/qcom_glink_native.c
> @@ -635,19 +635,18 @@ qcom_glink_alloc_intent(struct qcom_glink *glink,
>  	unsigned long flags;
>  
>  	intent = kzalloc(sizeof(*intent), GFP_KERNEL);
> -
>  	if (!intent)
>  		return NULL;
>  
>  	intent->data = kzalloc(size, GFP_KERNEL);
>  	if (!intent->data)
> -		return NULL;
> +		goto free_intent;
>  
>  	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);
> -		return NULL;
> +		goto free_data;
>  	}
>  	spin_unlock_irqrestore(&channel->intent_lock, flags);
>  
> @@ -656,6 +655,12 @@ qcom_glink_alloc_intent(struct qcom_glink *glink,
>  	intent->reuse = reuseable;
>  
>  	return intent;
> +
> +free_data:
> +	kfree(intent->data);
> +free_intent:
> +	kfree(intent);
> +	return NULL;

Acked-by: Sricharan R <sricharan@codeaurora.org>

Regards,
 Sricharan

-- 
"QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-09-08 11:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-08 10:33 [PATCH 1/2] rpmsg: glink: Unlock on error in qcom_glink_request_intent() Dan Carpenter
2017-09-08 10:34 ` [PATCH 2/2] rpmsg: glink: Fix memory leak in qcom_glink_alloc_intent() Dan Carpenter
2017-09-08 11:14   ` Sricharan R
2017-09-08 11:13 ` [PATCH 1/2] rpmsg: glink: Unlock on error in qcom_glink_request_intent() Sricharan R

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox