Skip to content

Commit 1d7b33f

Browse files
Inaky Perez-Gonzalezdavem330
authored andcommitted
wimax: fix oops in wimax_dev_get_by_genl_info() when looking up non-wimax iface
When a non-wimax interface is looked up by the stack, a bad pointer is returned when the looked-up interface is not found in the list (of registered WiMAX interfaces). This causes an oops in the caller when trying to use the pointer. Fix by properly setting the pointer to NULL if we don't exit from the list_for_each() with a found entry. Signed-off-by: Inaky Perez-Gonzalez <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent df0bca0 commit 1d7b33f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

net/wimax/id-table.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,13 @@ struct wimax_dev *wimax_dev_get_by_genl_info(
9494
list_for_each_entry(wimax_dev, &wimax_id_table, id_table_node) {
9595
if (wimax_dev->net_dev->ifindex == ifindex) {
9696
dev_hold(wimax_dev->net_dev);
97-
break;
97+
goto found;
9898
}
9999
}
100-
if (wimax_dev == NULL)
101-
d_printf(1, NULL, "wimax: no devices found with ifindex %d\n",
102-
ifindex);
100+
wimax_dev = NULL;
101+
d_printf(1, NULL, "wimax: no devices found with ifindex %d\n",
102+
ifindex);
103+
found:
103104
spin_unlock(&wimax_id_table_lock);
104105
d_fnend(3, NULL, "(info %p ifindex %d) = %p\n",
105106
info, ifindex, wimax_dev);

0 commit comments

Comments
 (0)