Commit 7404368c authored by Per Forlin's avatar Per Forlin Committed by Vinod Koul

dmaengine/ste_dma40: fix Oops due to double free of client descriptor

The client list may exist in two lists at the same time. This makes free
fail since the same desc is freed multiple times. Remove desc from
client list when adding it to the pending queue. Move free of client owned
descriptors from free_dma() to terminate_all().

Unable to handle kernel paging request at virtual address 00100104
pgd = dea8c000
[00100104] *pgd=1ea62831, *pte=00000000, *ppte=00000000
Internal error: Oops: 817 [#1] PREEMPT SMP
Modules linked in:
CPU: 0    Not tainted  (3.1.0-rc3+ #58)
PC is at d40_free_chan_resources+0x64/0x330
Signed-off-by: default avatarPer Forlin <per.forlin@linaro.org>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarVinod Koul <vinod.koul@intel.com>
parent 3b3d5b0f
...@@ -644,8 +644,11 @@ static struct d40_desc *d40_first_active_get(struct d40_chan *d40c) ...@@ -644,8 +644,11 @@ static struct d40_desc *d40_first_active_get(struct d40_chan *d40c)
return d; return d;
} }
/* remove desc from current queue and add it to the pending_queue */
static void d40_desc_queue(struct d40_chan *d40c, struct d40_desc *desc) static void d40_desc_queue(struct d40_chan *d40c, struct d40_desc *desc)
{ {
d40_desc_remove(desc);
desc->is_in_client_list = false;
list_add_tail(&desc->node, &d40c->pending_queue); list_add_tail(&desc->node, &d40c->pending_queue);
} }
...@@ -803,6 +806,7 @@ static int d40_channel_execute_command(struct d40_chan *d40c, ...@@ -803,6 +806,7 @@ static int d40_channel_execute_command(struct d40_chan *d40c,
static void d40_term_all(struct d40_chan *d40c) static void d40_term_all(struct d40_chan *d40c)
{ {
struct d40_desc *d40d; struct d40_desc *d40d;
struct d40_desc *_d;
/* Release active descriptors */ /* Release active descriptors */
while ((d40d = d40_first_active_get(d40c))) { while ((d40d = d40_first_active_get(d40c))) {
...@@ -822,6 +826,14 @@ static void d40_term_all(struct d40_chan *d40c) ...@@ -822,6 +826,14 @@ static void d40_term_all(struct d40_chan *d40c)
d40_desc_free(d40c, d40d); d40_desc_free(d40c, d40d);
} }
/* Release client owned descriptors */
if (!list_empty(&d40c->client))
list_for_each_entry_safe(d40d, _d, &d40c->client, node) {
d40_desc_remove(d40d);
d40_desc_free(d40c, d40d);
}
d40c->pending_tx = 0; d40c->pending_tx = 0;
d40c->busy = false; d40c->busy = false;
} }
...@@ -1594,20 +1606,10 @@ static int d40_free_dma(struct d40_chan *d40c) ...@@ -1594,20 +1606,10 @@ static int d40_free_dma(struct d40_chan *d40c)
u32 event; u32 event;
struct d40_phy_res *phy = d40c->phy_chan; struct d40_phy_res *phy = d40c->phy_chan;
bool is_src; bool is_src;
struct d40_desc *d;
struct d40_desc *_d;
/* Terminate all queued and active transfers */ /* Terminate all queued and active transfers */
d40_term_all(d40c); d40_term_all(d40c);
/* Release client owned descriptors */
if (!list_empty(&d40c->client))
list_for_each_entry_safe(d, _d, &d40c->client, node) {
d40_desc_remove(d);
d40_desc_free(d40c, d);
}
if (phy == NULL) { if (phy == NULL) {
chan_err(d40c, "phy == null\n"); chan_err(d40c, "phy == null\n");
return -EINVAL; return -EINVAL;
......
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