iwlwifi: fix use after free bug for paged rx
In the paged rx patch (4854fde2), I introduced a bug that could possibly touch an already freed page. It is fixed by avoiding the access in this patch. I've also added some comments so that other people touching the code won't make the same mistake. In the future, if we cannot avoid access the page after being handled to the upper layer, we can use get_page/put_page to handle it. For now, it's just not necessary. It also fixed a debug message print bug reported by Stanislaw Gruszka <sgruszka@redhat.com>. Signed-off-by: Zhu Yi <yi.zhu@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
@@ -814,8 +814,8 @@ void iwl_rx_handle(struct iwl_priv *priv)
|
||||
if (priv->rx_handlers[pkt->hdr.cmd]) {
|
||||
IWL_DEBUG_RX(priv, "r = %d, i = %d, %s, 0x%02x\n", r,
|
||||
i, get_cmd_string(pkt->hdr.cmd), pkt->hdr.cmd);
|
||||
priv->rx_handlers[pkt->hdr.cmd] (priv, rxb);
|
||||
priv->isr_stats.rx_handlers[pkt->hdr.cmd]++;
|
||||
priv->rx_handlers[pkt->hdr.cmd] (priv, rxb);
|
||||
} else {
|
||||
/* No handling needed */
|
||||
IWL_DEBUG_RX(priv,
|
||||
@@ -824,11 +824,18 @@ void iwl_rx_handle(struct iwl_priv *priv)
|
||||
pkt->hdr.cmd);
|
||||
}
|
||||
|
||||
/*
|
||||
* XXX: After here, we should always check rxb->page
|
||||
* against NULL before touching it or its virtual
|
||||
* memory (pkt). Because some rx_handler might have
|
||||
* already taken or freed the pages.
|
||||
*/
|
||||
|
||||
if (reclaim) {
|
||||
/* Invoke any callbacks, transfer the buffer to caller,
|
||||
* and fire off the (possibly) blocking iwl_send_cmd()
|
||||
* as we reclaim the driver command queue */
|
||||
if (rxb && rxb->page)
|
||||
if (rxb->page)
|
||||
iwl_tx_cmd_complete(priv, rxb);
|
||||
else
|
||||
IWL_WARN(priv, "Claim null rxb?\n");
|
||||
|
Reference in New Issue
Block a user