diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-10-11 15:01:38 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-10-11 15:01:38 -0400 |
commit | ff5abbe799e29099695cb8b5b2f198dd8b8bdf26 (patch) | |
tree | 36110a37ecbe774d9702041a12153b3e7b421ff3 | |
parent | 9add7e3e368cbb28aa773a1817c41861ce96c078 (diff) | |
parent | b775d158530285c9657a1a0628c139b0dfd0d2e5 (diff) |
Merge tag 'rpmsg-v4.14-fixes' of git://github.com/andersson/remoteproc
Pull rpmsg fixes from Bjorn Andersson:
"This corrects two mistakes in the Qualcomm GLINK SMEM driver"
* tag 'rpmsg-v4.14-fixes' of git://github.com/andersson/remoteproc:
rpmsg: glink: Fix memory leak in qcom_glink_alloc_intent()
rpmsg: glink: Unlock on error in qcom_glink_request_intent()
-rw-r--r-- | drivers/rpmsg/qcom_glink_native.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/rpmsg/qcom_glink_native.c b/drivers/rpmsg/qcom_glink_native.c index 5a5e927ea50f..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, | |||
635 | unsigned long flags; | 635 | unsigned long flags; |
636 | 636 | ||
637 | intent = kzalloc(sizeof(*intent), GFP_KERNEL); | 637 | intent = kzalloc(sizeof(*intent), GFP_KERNEL); |
638 | |||
639 | if (!intent) | 638 | if (!intent) |
640 | return NULL; | 639 | return NULL; |
641 | 640 | ||
642 | intent->data = kzalloc(size, GFP_KERNEL); | 641 | intent->data = kzalloc(size, GFP_KERNEL); |
643 | if (!intent->data) | 642 | if (!intent->data) |
644 | return NULL; | 643 | goto free_intent; |
645 | 644 | ||
646 | spin_lock_irqsave(&channel->intent_lock, flags); | 645 | spin_lock_irqsave(&channel->intent_lock, flags); |
647 | ret = idr_alloc_cyclic(&channel->liids, intent, 1, -1, GFP_ATOMIC); | 646 | ret = idr_alloc_cyclic(&channel->liids, intent, 1, -1, GFP_ATOMIC); |
648 | if (ret < 0) { | 647 | if (ret < 0) { |
649 | spin_unlock_irqrestore(&channel->intent_lock, flags); | 648 | spin_unlock_irqrestore(&channel->intent_lock, flags); |
650 | return NULL; | 649 | goto free_data; |
651 | } | 650 | } |
652 | spin_unlock_irqrestore(&channel->intent_lock, flags); | 651 | spin_unlock_irqrestore(&channel->intent_lock, flags); |
653 | 652 | ||
@@ -656,6 +655,12 @@ qcom_glink_alloc_intent(struct qcom_glink *glink, | |||
656 | intent->reuse = reuseable; | 655 | intent->reuse = reuseable; |
657 | 656 | ||
658 | return intent; | 657 | return intent; |
658 | |||
659 | free_data: | ||
660 | kfree(intent->data); | ||
661 | free_intent: | ||
662 | kfree(intent); | ||
663 | return NULL; | ||
659 | } | 664 | } |
660 | 665 | ||
661 | static void qcom_glink_handle_rx_done(struct qcom_glink *glink, | 666 | static void qcom_glink_handle_rx_done(struct qcom_glink *glink, |
@@ -1197,7 +1202,7 @@ static int qcom_glink_request_intent(struct qcom_glink *glink, | |||
1197 | 1202 | ||
1198 | ret = qcom_glink_tx(glink, &cmd, sizeof(cmd), NULL, 0, true); | 1203 | ret = qcom_glink_tx(glink, &cmd, sizeof(cmd), NULL, 0, true); |
1199 | if (ret) | 1204 | if (ret) |
1200 | return ret; | 1205 | goto unlock; |
1201 | 1206 | ||
1202 | ret = wait_for_completion_timeout(&channel->intent_req_comp, 10 * HZ); | 1207 | ret = wait_for_completion_timeout(&channel->intent_req_comp, 10 * HZ); |
1203 | if (!ret) { | 1208 | if (!ret) { |
@@ -1207,6 +1212,7 @@ static int qcom_glink_request_intent(struct qcom_glink *glink, | |||
1207 | ret = channel->intent_req_result ? 0 : -ECANCELED; | 1212 | ret = channel->intent_req_result ? 0 : -ECANCELED; |
1208 | } | 1213 | } |
1209 | 1214 | ||
1215 | unlock: | ||
1210 | mutex_unlock(&channel->intent_req_lock); | 1216 | mutex_unlock(&channel->intent_req_lock); |
1211 | return ret; | 1217 | return ret; |
1212 | } | 1218 | } |