qcacmn: Fix list iterators to match upstream discussion
List iterators should conform to upstream discussion. List iterators that reach end of list do not point to NULL but rather they point to list_head. Dereferencing the iterator in this case would break the list. The scope of the list iterator should be confined to the loop. Solution is to use assign ptr to iterator when condition is met, this ptr can be used outside of the loop. Change-Id: I896b85bbd24b63e6b1562d35ffec8abc920f1b6d CRs-Fixed: 3331681
This commit is contained in:

committed by
Madan Koyyalamudi

parent
e3496e0420
commit
3ccef6c0a6
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2019 The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for
|
||||
* any purpose with or without fee is hereby granted, provided that the
|
||||
@@ -146,20 +147,26 @@ qdf_export_symbol(qld_register);
|
||||
int qld_unregister(void *addr)
|
||||
{
|
||||
struct qld_node *qld = NULL;
|
||||
struct qld_node *cur_entry;
|
||||
|
||||
if (!qld_handle || !addr) {
|
||||
qld_err("Handle or address is NULL");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
qdf_spinlock_acquire(&qld_handle->qld_lock);
|
||||
qdf_list_for_each(&qld_handle->qld_list, qld, node) {
|
||||
if (qld->entry.addr == (uintptr_t)addr)
|
||||
qdf_list_for_each(&qld_handle->qld_list, cur_entry, node) {
|
||||
if (cur_entry->entry.addr == (uintptr_t)addr) {
|
||||
qld = cur_entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (qld) {
|
||||
qdf_list_remove_node(&qld_handle->qld_list, &qld->node);
|
||||
qld_debug("Delete name=%s, size=%zu", qld->entry.name,
|
||||
qld->entry.size);
|
||||
qdf_mem_free(qld);
|
||||
}
|
||||
qdf_list_remove_node(&qld_handle->qld_list, &qld->node);
|
||||
qld_debug("Delete name=%s, size=%zu", qld->entry.name, qld->entry.size);
|
||||
qdf_mem_free(qld);
|
||||
qdf_spinlock_release(&qld_handle->qld_lock);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user