soc: qcom: rpmh: Correct rpm_msg pointer offset and add list_del

rpm_msgs address is calculated from memory allocated during write_batch.
Correct the offset from where rpm_msgs actually starts and assign req
pointer to point to correct address.

Also add list_del before freeing memory in rpmh_invalidate.

Change-Id: Idca43fe73bd238e90911158b08b3889c001e1123
Signed-off-by: Maulik Shah <quic_mkshah@quicinc.com>
This commit is contained in:
Maulik Shah 2019-11-18 18:15:15 +05:30 committed by Gerrit - the friendly Code Review server
parent c02c62a522
commit 8d44aff55c

View File

@ -66,7 +66,7 @@ struct cache_req {
struct batch_cache_req {
struct list_head list;
int count;
struct rpmh_request rpm_msgs[];
struct rpmh_request *rpm_msgs;
};
static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev)
@ -393,10 +393,11 @@ int rpmh_write_batch(const struct device *dev, enum rpmh_state state,
return -ENOMEM;
req = ptr;
rpm_msgs = ptr + sizeof(*req);
compls = ptr + sizeof(*req) + count * sizeof(*rpm_msgs);
req->count = count;
rpm_msgs = req->rpm_msgs;
req->rpm_msgs = rpm_msgs;
for (i = 0; i < count; i++) {
__fill_rpmh_msg(rpm_msgs + i, state, cmd, n[i]);
@ -577,8 +578,11 @@ void rpmh_invalidate(const struct device *dev)
return;
spin_lock_irqsave(&ctrlr->cache_lock, flags);
list_for_each_entry_safe(req, tmp, &ctrlr->batch_cache, list)
list_for_each_entry_safe(req, tmp, &ctrlr->batch_cache, list) {
list_del(&req->list);
kfree(req);
}
INIT_LIST_HEAD(&ctrlr->batch_cache);
ctrlr->dirty = true;
spin_unlock_irqrestore(&ctrlr->cache_lock, flags);