Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rapidio: fix use after free in rio_unregister_scan()

We're freeing the list iterator so we can't move to the next entry.
Since there is only one matching mport_id, we can just break after
finding it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Ryan Mallon <rmallon@gmail.com>
Acked-by: Alexandre Bounine <alexandre.bounine@idt.com>
Cc: Matt Porter <mporter@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Dan Carpenter and committed by
Linus Torvalds
f93f3c4e 4e505294

+3 -1
+3 -1
drivers/rapidio/rio.c
··· 1715 1715 (mport_id == RIO_MPORT_ANY && port->nscan == scan_ops)) 1716 1716 port->nscan = NULL; 1717 1717 1718 - list_for_each_entry(scan, &rio_scans, node) 1718 + list_for_each_entry(scan, &rio_scans, node) { 1719 1719 if (scan->mport_id == mport_id) { 1720 1720 list_del(&scan->node); 1721 1721 kfree(scan); 1722 + break; 1722 1723 } 1724 + } 1723 1725 1724 1726 mutex_unlock(&rio_mport_list_lock); 1725 1727