ACPI: EC: acpi_ec_remove(): fix use-after-free

This patch fixes an obvious use-after-free introduced by
commit 837012ede14a8fc088be3682c964da7fc6af026b.

Spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@stusta.de>
Acked-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>

authored by Adrian Bunk and committed by Len Brown 07ddf768 7c010de7

+2 -2
+2 -2
drivers/acpi/ec.c
··· 730 730 static int acpi_ec_remove(struct acpi_device *device, int type) 731 731 { 732 732 struct acpi_ec *ec; 733 - struct acpi_ec_query_handler *handler; 733 + struct acpi_ec_query_handler *handler, *tmp; 734 734 735 735 if (!device) 736 736 return -EINVAL; 737 737 738 738 ec = acpi_driver_data(device); 739 739 mutex_lock(&ec->lock); 740 - list_for_each_entry(handler, &ec->list, node) { 740 + list_for_each_entry_safe(handler, tmp, &ec->list, node) { 741 741 list_del(&handler->node); 742 742 kfree(handler); 743 743 }