Skip to content

Commit b2de364

Browse files
tititiou36mchehab
authored andcommitted
media: cx25821: Fix a bug when reallocating some dma memory
This function looks like a realloc. However, if 'risc->cpu != NULL', the memory will be freed, but never reallocated with the bigger 'size'. Explicitly set 'risc->cpu' to NULL, so that the reallocation is correctly performed a few lines below. [hverkuil: NULL != risc->cpu -> risc->cpu] Fixes: 5ede94c ("[media] cx25821: remove bogus btcx_risc dependency) Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent 873a623 commit b2de364

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/media/pci/cx25821/cx25821-core.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,10 @@ int cx25821_riscmem_alloc(struct pci_dev *pci,
976976
__le32 *cpu;
977977
dma_addr_t dma = 0;
978978

979-
if (NULL != risc->cpu && risc->size < size)
979+
if (risc->cpu && risc->size < size) {
980980
pci_free_consistent(pci, risc->size, risc->cpu, risc->dma);
981+
risc->cpu = NULL;
982+
}
981983
if (NULL == risc->cpu) {
982984
cpu = pci_zalloc_consistent(pci, size, &dma);
983985
if (NULL == cpu)

0 commit comments

Comments
 (0)