qed: Fix SPQ entries not returned to pool in error flows
[sfrench/cifs-2.6.git] / drivers / net / ethernet / qlogic / qed / qed_sp_commands.c
index e86a1ea23613303b0070618a8ffb9319993eec30..888274fa208bc768b2ab9db2514407573bfab2e1 100644 (file)
 #include "qed_sp.h"
 #include "qed_sriov.h"
 
+void qed_sp_destroy_request(struct qed_hwfn *p_hwfn,
+                           struct qed_spq_entry *p_ent)
+{
+       /* qed_spq_get_entry() can either get an entry from the free_pool,
+        * or, if no entries are left, allocate a new entry and add it to
+        * the unlimited_pending list.
+        */
+       if (p_ent->queue == &p_hwfn->p_spq->unlimited_pending)
+               kfree(p_ent);
+       else
+               qed_spq_return_entry(p_hwfn, p_ent);
+}
+
 int qed_sp_init_request(struct qed_hwfn *p_hwfn,
                        struct qed_spq_entry **pp_ent,
                        u8 cmd, u8 protocol, struct qed_sp_init_data *p_data)
@@ -111,14 +124,7 @@ int qed_sp_init_request(struct qed_hwfn *p_hwfn,
        return 0;
 
 err:
-       /* qed_spq_get_entry() can either get an entry from the free_pool,
-        * or, if no entries are left, allocate a new entry and add it to
-        * the unlimited_pending list.
-        */
-       if (p_ent->queue == &p_hwfn->p_spq->unlimited_pending)
-               kfree(p_ent);
-       else
-               qed_spq_return_entry(p_hwfn, p_ent);
+       qed_sp_destroy_request(p_hwfn, p_ent);
 
        return -EINVAL;
 }