vme: vme_ca91cx42.c: use list_for_each_safe() when delete list items
Since we will be removing items off the list using list_del() we need to use a safer version of the list_for_each() macro aptly named list_for_each_safe(). We should use the safe macro if the loop involves deletions of items. Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Родитель
b49c32ba2c
Коммит
43f5e46c8e
|
@ -1603,7 +1603,7 @@ static int ca91cx42_probe(struct pci_dev *pdev, const struct pci_device_id *id)
|
||||||
{
|
{
|
||||||
int retval, i;
|
int retval, i;
|
||||||
u32 data;
|
u32 data;
|
||||||
struct list_head *pos = NULL;
|
struct list_head *pos = NULL, *n;
|
||||||
struct vme_bridge *ca91cx42_bridge;
|
struct vme_bridge *ca91cx42_bridge;
|
||||||
struct ca91cx42_driver *ca91cx42_device;
|
struct ca91cx42_driver *ca91cx42_device;
|
||||||
struct vme_master_resource *master_image;
|
struct vme_master_resource *master_image;
|
||||||
|
@ -1821,28 +1821,28 @@ err_reg:
|
||||||
ca91cx42_crcsr_exit(ca91cx42_bridge, pdev);
|
ca91cx42_crcsr_exit(ca91cx42_bridge, pdev);
|
||||||
err_lm:
|
err_lm:
|
||||||
/* resources are stored in link list */
|
/* resources are stored in link list */
|
||||||
list_for_each(pos, &ca91cx42_bridge->lm_resources) {
|
list_for_each_safe(pos, n, &ca91cx42_bridge->lm_resources) {
|
||||||
lm = list_entry(pos, struct vme_lm_resource, list);
|
lm = list_entry(pos, struct vme_lm_resource, list);
|
||||||
list_del(pos);
|
list_del(pos);
|
||||||
kfree(lm);
|
kfree(lm);
|
||||||
}
|
}
|
||||||
err_dma:
|
err_dma:
|
||||||
/* resources are stored in link list */
|
/* resources are stored in link list */
|
||||||
list_for_each(pos, &ca91cx42_bridge->dma_resources) {
|
list_for_each_safe(pos, n, &ca91cx42_bridge->dma_resources) {
|
||||||
dma_ctrlr = list_entry(pos, struct vme_dma_resource, list);
|
dma_ctrlr = list_entry(pos, struct vme_dma_resource, list);
|
||||||
list_del(pos);
|
list_del(pos);
|
||||||
kfree(dma_ctrlr);
|
kfree(dma_ctrlr);
|
||||||
}
|
}
|
||||||
err_slave:
|
err_slave:
|
||||||
/* resources are stored in link list */
|
/* resources are stored in link list */
|
||||||
list_for_each(pos, &ca91cx42_bridge->slave_resources) {
|
list_for_each_safe(pos, n, &ca91cx42_bridge->slave_resources) {
|
||||||
slave_image = list_entry(pos, struct vme_slave_resource, list);
|
slave_image = list_entry(pos, struct vme_slave_resource, list);
|
||||||
list_del(pos);
|
list_del(pos);
|
||||||
kfree(slave_image);
|
kfree(slave_image);
|
||||||
}
|
}
|
||||||
err_master:
|
err_master:
|
||||||
/* resources are stored in link list */
|
/* resources are stored in link list */
|
||||||
list_for_each(pos, &ca91cx42_bridge->master_resources) {
|
list_for_each_safe(pos, n, &ca91cx42_bridge->master_resources) {
|
||||||
master_image = list_entry(pos, struct vme_master_resource,
|
master_image = list_entry(pos, struct vme_master_resource,
|
||||||
list);
|
list);
|
||||||
list_del(pos);
|
list_del(pos);
|
||||||
|
@ -1868,7 +1868,7 @@ err_struct:
|
||||||
|
|
||||||
static void ca91cx42_remove(struct pci_dev *pdev)
|
static void ca91cx42_remove(struct pci_dev *pdev)
|
||||||
{
|
{
|
||||||
struct list_head *pos = NULL;
|
struct list_head *pos = NULL, *n;
|
||||||
struct vme_master_resource *master_image;
|
struct vme_master_resource *master_image;
|
||||||
struct vme_slave_resource *slave_image;
|
struct vme_slave_resource *slave_image;
|
||||||
struct vme_dma_resource *dma_ctrlr;
|
struct vme_dma_resource *dma_ctrlr;
|
||||||
|
@ -1905,28 +1905,28 @@ static void ca91cx42_remove(struct pci_dev *pdev)
|
||||||
ca91cx42_crcsr_exit(ca91cx42_bridge, pdev);
|
ca91cx42_crcsr_exit(ca91cx42_bridge, pdev);
|
||||||
|
|
||||||
/* resources are stored in link list */
|
/* resources are stored in link list */
|
||||||
list_for_each(pos, &ca91cx42_bridge->lm_resources) {
|
list_for_each_safe(pos, n, &ca91cx42_bridge->lm_resources) {
|
||||||
lm = list_entry(pos, struct vme_lm_resource, list);
|
lm = list_entry(pos, struct vme_lm_resource, list);
|
||||||
list_del(pos);
|
list_del(pos);
|
||||||
kfree(lm);
|
kfree(lm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* resources are stored in link list */
|
/* resources are stored in link list */
|
||||||
list_for_each(pos, &ca91cx42_bridge->dma_resources) {
|
list_for_each_safe(pos, n, &ca91cx42_bridge->dma_resources) {
|
||||||
dma_ctrlr = list_entry(pos, struct vme_dma_resource, list);
|
dma_ctrlr = list_entry(pos, struct vme_dma_resource, list);
|
||||||
list_del(pos);
|
list_del(pos);
|
||||||
kfree(dma_ctrlr);
|
kfree(dma_ctrlr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* resources are stored in link list */
|
/* resources are stored in link list */
|
||||||
list_for_each(pos, &ca91cx42_bridge->slave_resources) {
|
list_for_each_safe(pos, n, &ca91cx42_bridge->slave_resources) {
|
||||||
slave_image = list_entry(pos, struct vme_slave_resource, list);
|
slave_image = list_entry(pos, struct vme_slave_resource, list);
|
||||||
list_del(pos);
|
list_del(pos);
|
||||||
kfree(slave_image);
|
kfree(slave_image);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* resources are stored in link list */
|
/* resources are stored in link list */
|
||||||
list_for_each(pos, &ca91cx42_bridge->master_resources) {
|
list_for_each_safe(pos, n, &ca91cx42_bridge->master_resources) {
|
||||||
master_image = list_entry(pos, struct vme_master_resource,
|
master_image = list_entry(pos, struct vme_master_resource,
|
||||||
list);
|
list);
|
||||||
list_del(pos);
|
list_del(pos);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче