From: Axel Lin Date: Mon, 3 Nov 2014 18:21:54 +0000 (-0800) Subject: soc: ti: knav_qmss_queue: Use list_for_each_entry_safe to prevent use after free X-Git-Tag: firefly_0821_release~176^2~2767^2~13^2 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=148bb0439adeeae466dca31dd4c643e194bee023;p=firefly-linux-kernel-4.4.55.git soc: ti: knav_qmss_queue: Use list_for_each_entry_safe to prevent use after free list_for_each_entry_safe() is necessary if list objects are deleted from the list while traversing it. Signed-off-by: Axel Lin Signed-off-by: Santosh Shilimkar --- diff --git a/drivers/soc/ti/knav_qmss_queue.c b/drivers/soc/ti/knav_qmss_queue.c index 6f22d5622c98..9b8dd6732681 100644 --- a/drivers/soc/ti/knav_qmss_queue.c +++ b/drivers/soc/ti/knav_qmss_queue.c @@ -1306,14 +1306,14 @@ static void knav_free_queue_ranges(struct knav_device *kdev) static void knav_queue_free_regions(struct knav_device *kdev) { struct knav_region *region; - struct knav_pool *pool; + struct knav_pool *pool, *tmp; unsigned size; for (;;) { region = first_region(kdev); if (!region) break; - list_for_each_entry(pool, ®ion->pools, region_inst) + list_for_each_entry_safe(pool, tmp, ®ion->pools, region_inst) knav_pool_destroy(pool); size = region->virt_end - region->virt_start;