Patch "dmaengine: Fix a double free in dma_async_device_register" has been added to the 5.11-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    dmaengine: Fix a double free in dma_async_device_register

to the 5.11-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     dmaengine-fix-a-double-free-in-dma_async_device_regi.patch
and it can be found in the queue-5.11 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 3aae7d2464ebfdeea75fbbe203bc9f77847b6d53
Author: Lv Yunlong <lyl2019@xxxxxxxxxxxxxxxx>
Date:   Tue Mar 30 18:44:58 2021 -0700

    dmaengine: Fix a double free in dma_async_device_register
    
    [ Upstream commit ea45b6008f8095db0cc09ad6e03c7785c2986197 ]
    
    In the first list_for_each_entry() macro of dma_async_device_register,
    it gets the chan from list and calls __dma_async_device_channel_register
    (..,chan). We can see that chan->local is allocated by alloc_percpu() and
    it is freed chan->local by free_percpu(chan->local) when
    __dma_async_device_channel_register() failed.
    
    But after __dma_async_device_channel_register() failed, the caller will
    goto err_out and freed the chan->local in the second time by free_percpu().
    
    The cause of this problem is forget to set chan->local to NULL when
    chan->local was freed in __dma_async_device_channel_register(). My
    patch sets chan->local to NULL when the callee failed to avoid double free.
    
    Fixes: d2fb0a0438384 ("dmaengine: break out channel registration")
    Signed-off-by: Lv Yunlong <lyl2019@xxxxxxxxxxxxxxxx>
    Reviewed-by: Dave Jiang <dave.jiang@xxxxxxxxx>
    Link: https://lore.kernel.org/r/20210331014458.3944-1-lyl2019@xxxxxxxxxxxxxxxx
    Signed-off-by: Vinod Koul <vkoul@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index fe6a460c4373..af3ee288bc11 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -1086,6 +1086,7 @@ static int __dma_async_device_channel_register(struct dma_device *device,
 	kfree(chan->dev);
  err_free_local:
 	free_percpu(chan->local);
+	chan->local = NULL;
 	return rc;
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux