Skip to content

Commit ff5abbe

Browse files
committed
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()
2 parents 9add7e3 + b775d15 commit ff5abbe

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎drivers/rpmsg/qcom_glink_native.c‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -635,19 +635,18 @@ qcom_glink_alloc_intent(struct qcom_glink *glink,
635635
unsigned long flags;
636636

637637
intent = kzalloc(sizeof(*intent), GFP_KERNEL);
638-
639638
if (!intent)
640639
return NULL;
641640

642641
intent->data = kzalloc(size, GFP_KERNEL);
643642
if (!intent->data)
644-
return NULL;
643+
goto free_intent;
645644

646645
spin_lock_irqsave(&channel->intent_lock, flags);
647646
ret = idr_alloc_cyclic(&channel->liids, intent, 1, -1, GFP_ATOMIC);
648647
if (ret < 0) {
649648
spin_unlock_irqrestore(&channel->intent_lock, flags);
650-
return NULL;
649+
goto free_data;
651650
}
652651
spin_unlock_irqrestore(&channel->intent_lock, flags);
653652

@@ -656,6 +655,12 @@ qcom_glink_alloc_intent(struct qcom_glink *glink,
656655
intent->reuse = reuseable;
657656

658657
return intent;
658+
659+
free_data:
660+
kfree(intent->data);
661+
free_intent:
662+
kfree(intent);
663+
return NULL;
659664
}
660665

661666
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,
11971202

11981203
ret = qcom_glink_tx(glink, &cmd, sizeof(cmd), NULL, 0, true);
11991204
if (ret)
1200-
return ret;
1205+
goto unlock;
12011206

12021207
ret = wait_for_completion_timeout(&channel->intent_req_comp, 10 * HZ);
12031208
if (!ret) {
@@ -1207,6 +1212,7 @@ static int qcom_glink_request_intent(struct qcom_glink *glink,
12071212
ret = channel->intent_req_result ? 0 : -ECANCELED;
12081213
}
12091214

1215+
unlock:
12101216
mutex_unlock(&channel->intent_req_lock);
12111217
return ret;
12121218
}

0 commit comments

Comments
 (0)