Skip to content

Commit fa5c448

Browse files
sozeridavem330
authored andcommitted
qed: Fix potential memory corruption
A stuck ramrod should be deleted from the completion_pending list, otherwise it will be added again in the future and corrupt the list. Return error value to inform that ramrod is stuck and should be deleted. Signed-off-by: Sagiv Ozeri <sagiv.ozeri@cavium.com> Signed-off-by: Denis Bolotin <denis.bolotin@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fb5e743 commit fa5c448

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

drivers/net/ethernet/qlogic/qed/qed_spq.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ static int qed_spq_block(struct qed_hwfn *p_hwfn,
142142

143143
DP_INFO(p_hwfn, "Ramrod is stuck, requesting MCP drain\n");
144144
rc = qed_mcp_drain(p_hwfn, p_ptt);
145+
qed_ptt_release(p_hwfn, p_ptt);
145146
if (rc) {
146147
DP_NOTICE(p_hwfn, "MCP drain failed\n");
147148
goto err;
@@ -150,18 +151,15 @@ static int qed_spq_block(struct qed_hwfn *p_hwfn,
150151
/* Retry after drain */
151152
rc = __qed_spq_block(p_hwfn, p_ent, p_fw_ret, true);
152153
if (!rc)
153-
goto out;
154+
return 0;
154155

155156
comp_done = (struct qed_spq_comp_done *)p_ent->comp_cb.cookie;
156-
if (comp_done->done == 1)
157+
if (comp_done->done == 1) {
157158
if (p_fw_ret)
158159
*p_fw_ret = comp_done->fw_return_code;
159-
out:
160-
qed_ptt_release(p_hwfn, p_ptt);
161-
return 0;
162-
160+
return 0;
161+
}
163162
err:
164-
qed_ptt_release(p_hwfn, p_ptt);
165163
DP_NOTICE(p_hwfn,
166164
"Ramrod is stuck [CID %08x cmd %02x protocol %02x echo %04x]\n",
167165
le32_to_cpu(p_ent->elem.hdr.cid),

0 commit comments

Comments
 (0)