Commit 552a3372 authored by Sukadev Bhattiprolu's avatar Sukadev Bhattiprolu Committed by David S. Miller

ibmvnic: set ltb->buff to NULL after freeing

free_long_term_buff() checks ltb->buff to decide whether we have a long
term buffer to free. So set ltb->buff to NULL afer freeing. While here,
also clear ->map_id, fix up some coding style and log an error.

Fixes: 9c4eaabd ("Check CRQ command return codes")
Signed-off-by: default avatarSukadev Bhattiprolu <sukadev@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 72368f8b
...@@ -211,12 +211,11 @@ static int alloc_long_term_buff(struct ibmvnic_adapter *adapter, ...@@ -211,12 +211,11 @@ static int alloc_long_term_buff(struct ibmvnic_adapter *adapter,
mutex_lock(&adapter->fw_lock); mutex_lock(&adapter->fw_lock);
adapter->fw_done_rc = 0; adapter->fw_done_rc = 0;
reinit_completion(&adapter->fw_done); reinit_completion(&adapter->fw_done);
rc = send_request_map(adapter, ltb->addr,
ltb->size, ltb->map_id); rc = send_request_map(adapter, ltb->addr, ltb->size, ltb->map_id);
if (rc) { if (rc) {
dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr); dev_err(dev, "send_request_map failed, rc = %d\n", rc);
mutex_unlock(&adapter->fw_lock); goto out;
return rc;
} }
rc = ibmvnic_wait_for_completion(adapter, &adapter->fw_done, 10000); rc = ibmvnic_wait_for_completion(adapter, &adapter->fw_done, 10000);
...@@ -224,20 +223,23 @@ static int alloc_long_term_buff(struct ibmvnic_adapter *adapter, ...@@ -224,20 +223,23 @@ static int alloc_long_term_buff(struct ibmvnic_adapter *adapter,
dev_err(dev, dev_err(dev,
"Long term map request aborted or timed out,rc = %d\n", "Long term map request aborted or timed out,rc = %d\n",
rc); rc);
dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr); goto out;
mutex_unlock(&adapter->fw_lock);
return rc;
} }
if (adapter->fw_done_rc) { if (adapter->fw_done_rc) {
dev_err(dev, "Couldn't map long term buffer,rc = %d\n", dev_err(dev, "Couldn't map long term buffer,rc = %d\n",
adapter->fw_done_rc); adapter->fw_done_rc);
rc = -1;
goto out;
}
rc = 0;
out:
if (rc) {
dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr); dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr);
mutex_unlock(&adapter->fw_lock); ltb->buff = NULL;
return -1;
} }
mutex_unlock(&adapter->fw_lock); mutex_unlock(&adapter->fw_lock);
return 0; return rc;
} }
static void free_long_term_buff(struct ibmvnic_adapter *adapter, static void free_long_term_buff(struct ibmvnic_adapter *adapter,
...@@ -257,6 +259,8 @@ static void free_long_term_buff(struct ibmvnic_adapter *adapter, ...@@ -257,6 +259,8 @@ static void free_long_term_buff(struct ibmvnic_adapter *adapter,
adapter->reset_reason != VNIC_RESET_TIMEOUT) adapter->reset_reason != VNIC_RESET_TIMEOUT)
send_request_unmap(adapter, ltb->map_id); send_request_unmap(adapter, ltb->map_id);
dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr); dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr);
ltb->buff = NULL;
ltb->map_id = 0;
} }
static int reset_long_term_buff(struct ibmvnic_adapter *adapter, static int reset_long_term_buff(struct ibmvnic_adapter *adapter,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment