diff options
author | Nick Ewalt <nicholasewalt@google.com> | 2018-10-15 07:59:22 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-10-15 17:30:37 +0300 |
commit | 54be7ec98875e3061e6ae788d6e7088cffa5ed2e (patch) | |
tree | 93e087df3b92fe62dbb5c9e145127cb8489da420 /drivers/staging | |
parent | 53f8a81d465b10aabaf6e0ffc99e7ea2c25bef5a (diff) | |
download | linux-54be7ec98875e3061e6ae788d6e7088cffa5ed2e.tar.xz |
staging: gasket: page table: fixup error path allocating coherent mem
Correctly clean up data structure state in gasket_alloc_coherent_memory
error path, to ensure no double free on the stale pointer value.
Signed-off-by: Nick Ewalt <nicholasewalt@google.com>
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/gasket/gasket_page_table.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/staging/gasket/gasket_page_table.c b/drivers/staging/gasket/gasket_page_table.c index 9c2f8671216b..a88f2ae0cee8 100644 --- a/drivers/staging/gasket/gasket_page_table.c +++ b/drivers/staging/gasket/gasket_page_table.c @@ -1332,9 +1332,13 @@ int gasket_alloc_coherent_memory(struct gasket_dev *gasket_dev, u64 size, return 0; nomem: - if (mem) + if (mem) { dma_free_coherent(gasket_get_device(gasket_dev), num_pages * PAGE_SIZE, mem, handle); + gasket_dev->coherent_buffer.length_bytes = 0; + gasket_dev->coherent_buffer.virt_base = NULL; + gasket_dev->coherent_buffer.phys_base = 0; + } kfree(gasket_dev->page_table[index]->coherent_pages); gasket_dev->page_table[index]->coherent_pages = NULL; |