Don't kmalloc(GFP_KERNEL) in atomic context
Crash was seen when performing ifup/ifdown repeatedly
in SpaceCast with receiver traffic. The problem is
found to be a delay inside spin_lock. Freescale provided
this patch for the problem. QA verified the fix.
Change-Id: Ie23751e23b05aba2bdf35252ef55a4d31c475b9d
Google-Bug-Id: 21621000
diff --git a/pfe_ctrl/pfe_hif_lib.c b/pfe_ctrl/pfe_hif_lib.c
index f12f0d7..40b4375 100644
--- a/pfe_ctrl/pfe_hif_lib.c
+++ b/pfe_ctrl/pfe_hif_lib.c
@@ -318,14 +318,7 @@
dbg_print_info("%s\n", __func__);
- spin_lock_bh(&pfe->hif.lock);
- if (!(client->pfe) || (client->id >= HIF_CLIENTS_MAX) || (pfe->hif_client[client->id])) {
- err = -EINVAL;
- goto err;
- }
-
- hif_shm = client->pfe->hif.shm;
-
+ /*Allocate memory before spin_lock*/
if (hif_lib_client_init_rx_buffers(client, client->rx_qsize)) {
err = -ENOMEM;
goto err_rx;
@@ -336,6 +329,14 @@
goto err_tx;
}
+ spin_lock_bh(&pfe->hif.lock);
+ if (!(client->pfe) || (client->id >= HIF_CLIENTS_MAX) || (pfe->hif_client[client->id])) {
+ err = -EINVAL;
+ goto err;
+ }
+
+ hif_shm = client->pfe->hif.shm;
+
if (!client->event_handler)
client->event_handler = hif_lib_event_dummy;
@@ -368,12 +369,14 @@
return 0;
+err:
+ spin_unlock_bh(&pfe->hif.lock);
+ hif_lib_client_release_tx_buffers(client);
+
err_tx:
hif_lib_client_release_rx_buffers(client);
err_rx:
-err:
- spin_unlock_bh(&pfe->hif.lock);
return err;
}