Commit c00d9738 authored by Cristian Marussi's avatar Cristian Marussi Committed by Sudeep Holla

firmware: arm_ffa: Check xa_load() return value

Add a check to verify the result of xa_load() during the partition
lookups done while registering/unregistering the scheduler receiver
interrupt callbacks and while executing the main scheduler receiver
interrupt callback handler.

Fixes: 0184450b ("firmware: arm_ffa: Add schedule receiver callback mechanism")
Signed-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
Link: https://lore.kernel.org/r/20240108-ffa_fixes_6-8-v1-3-75bf7035bc50@arm.comSigned-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
parent 5ff30ade
...@@ -733,6 +733,11 @@ static void __do_sched_recv_cb(u16 part_id, u16 vcpu, bool is_per_vcpu) ...@@ -733,6 +733,11 @@ static void __do_sched_recv_cb(u16 part_id, u16 vcpu, bool is_per_vcpu)
void *cb_data; void *cb_data;
partition = xa_load(&drv_info->partition_info, part_id); partition = xa_load(&drv_info->partition_info, part_id);
if (!partition) {
pr_err("%s: Invalid partition ID 0x%x\n", __func__, part_id);
return;
}
read_lock(&partition->rw_lock); read_lock(&partition->rw_lock);
callback = partition->callback; callback = partition->callback;
cb_data = partition->cb_data; cb_data = partition->cb_data;
...@@ -915,6 +920,11 @@ static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callback, ...@@ -915,6 +920,11 @@ static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callback,
return -EOPNOTSUPP; return -EOPNOTSUPP;
partition = xa_load(&drv_info->partition_info, part_id); partition = xa_load(&drv_info->partition_info, part_id);
if (!partition) {
pr_err("%s: Invalid partition ID 0x%x\n", __func__, part_id);
return -EINVAL;
}
write_lock(&partition->rw_lock); write_lock(&partition->rw_lock);
cb_valid = !!partition->callback; cb_valid = !!partition->callback;
......
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