ibmvnic fix NULL tx_pools and rx_tools issue at do_reset
authorMingming Cao <mmc@linux.vnet.ibm.com>
Tue, 25 Aug 2020 17:26:41 +0000 (13:26 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 26 Sep 2020 16:05:21 +0000 (18:05 +0200)
commit68c7abb8302ab8c67b07ab342a85a6e53ae1aab8
treef517bfbc624ebb12fccbfffc085d742b73a6a00a
parent16b1d77227fe8fedbded9e103c74bf83610f28b1
ibmvnic fix NULL tx_pools and rx_tools issue at do_reset

[ Upstream commit 9f13457377907fa253aef560e1a37e1ca4197f9b ]

At the time of do_rest, ibmvnic tries to re-initalize the tx_pools
and rx_pools to avoid re-allocating the long term buffer. However
there is a window inside do_reset that the tx_pools and
rx_pools were freed before re-initialized making it possible to deference
null pointers.

This patch fix this issue by always check the tx_pool
and rx_pool are not NULL after ibmvnic_login. If so, re-allocating
the pools. This will avoid getting into calling reset_tx/rx_pools with
NULL adapter tx_pools/rx_pools pointer. Also add null pointer check in
reset_tx_pools and reset_rx_pools to safe handle NULL pointer case.

Signed-off-by: Mingming Cao <mmc@linux.vnet.ibm.com>
Signed-off-by: Dany Madden <drt@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/ibm/ibmvnic.c