lkml.org 
[lkml]   [2021]   [Mar]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.11 228/775] media: cx25821: Fix a bug when reallocating some dma memory
    Date
    From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

    [ Upstream commit b2de3643c5024fc4fd128ba7767c7fb8b714bea7 ]

    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: 5ede94c70553 ("[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>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/media/pci/cx25821/cx25821-core.c | 4 +++-
    1 file changed, 3 insertions(+), 1 deletion(-)

    diff --git a/drivers/media/pci/cx25821/cx25821-core.c b/drivers/media/pci/cx25821/cx25821-core.c
    index 6f8ffab8840f4..07b6d0c49bbfa 100644
    --- a/drivers/media/pci/cx25821/cx25821-core.c
    +++ b/drivers/media/pci/cx25821/cx25821-core.c
    @@ -976,8 +976,10 @@ int cx25821_riscmem_alloc(struct pci_dev *pci,
    __le32 *cpu;
    dma_addr_t dma = 0;

    - if (NULL != risc->cpu && risc->size < size)
    + if (risc->cpu && risc->size < size) {
    pci_free_consistent(pci, risc->size, risc->cpu, risc->dma);
    + risc->cpu = NULL;
    + }
    if (NULL == risc->cpu) {
    cpu = pci_zalloc_consistent(pci, size, &dma);
    if (NULL == cpu)
    --
    2.27.0


    \
     
     \ /
      Last update: 2021-03-02 00:32    [W:4.092 / U:0.004 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site