Skip to content

Commit b2135d1

Browse files
Dan Carpenterakpm00
authored andcommitted
liveupdate: luo_file: don't use invalid list iterator
If we exit a list_for_each_entry() without hitting a break then the list iterator points to an offset from the list_head. It's a non-NULL but invalid pointer and dereferencing it isn't allowed. Introduce a new "found" variable to test instead. Link: https://lkml.kernel.org/r/aSlMc4SS09Re4_xn@stanley.mountain Fixes: 3ee1d67 ("liveupdate: luo_file: implement file systems callbacks") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/r/202511280420.y9O4fyhX-lkp@intel.com/ Reviewed-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com> Cc: Pratyush Yadav <pratyush@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent aa514a2 commit b2135d1

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

kernel/liveupdate/luo_file.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,17 +554,20 @@ int luo_retrieve_file(struct luo_file_set *file_set, u64 token,
554554
{
555555
struct liveupdate_file_op_args args = {0};
556556
struct luo_file *luo_file;
557+
bool found = false;
557558
int err;
558559

559560
if (list_empty(&file_set->files_list))
560561
return -ENOENT;
561562

562563
list_for_each_entry(luo_file, &file_set->files_list, list) {
563-
if (luo_file->token == token)
564+
if (luo_file->token == token) {
565+
found = true;
564566
break;
567+
}
565568
}
566569

567-
if (luo_file->token != token)
570+
if (!found)
568571
return -ENOENT;
569572

570573
guard(mutex)(&luo_file->mutex);

0 commit comments

Comments
 (0)