Skip to content

Commit a6848a5

Browse files
author
Sudeep Holla
committed
firmware: arm_ffa: Fix sched-recv callback partition lookup
ffa_sched_recv_cb_update() used list_for_each_entry_safe() to search for a matching partition and then tested the iterator against NULL. That is not a valid end-of-list check for circular lists and can fall through with an invalid pointer. Use a normal iterator and detect the not-found case correctly before touching the partition state. Fixes: be61da9 ("firmware: arm_ffa: Allow multiple UUIDs per partition to register SRI callback") Link: https://patch.msgid.link/20260428-ffa_fixes-v2-11-8595ae450034@kernel.org Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
1 parent 38290b1 commit a6848a5

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/firmware/arm_ffa/driver.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ static int
12071207
ffa_sched_recv_cb_update(struct ffa_device *dev, ffa_sched_recv_cb callback,
12081208
void *cb_data, bool is_registration)
12091209
{
1210-
struct ffa_dev_part_info *partition = NULL, *tmp;
1210+
struct ffa_dev_part_info *partition = NULL;
12111211
struct list_head *phead;
12121212
bool cb_valid;
12131213

@@ -1220,11 +1220,11 @@ ffa_sched_recv_cb_update(struct ffa_device *dev, ffa_sched_recv_cb callback,
12201220
return -EINVAL;
12211221
}
12221222

1223-
list_for_each_entry_safe(partition, tmp, phead, node)
1223+
list_for_each_entry(partition, phead, node)
12241224
if (partition->dev == dev)
12251225
break;
12261226

1227-
if (!partition) {
1227+
if (&partition->node == phead) {
12281228
pr_err("%s: No such partition ID 0x%x\n", __func__, dev->vm_id);
12291229
return -EINVAL;
12301230
}

0 commit comments

Comments
 (0)