EDAC: altera: Delete an inappropriate dma_free_coherent() call in altr_sdr_mc_err_inject_write()
Subsystems (3)
PATCH 1/1 EDAC: altera: Delete an inappropriate dma_free_coherent() call in altr_sdr_mc_err_inject_write()
dma_free_coherent() must only be called if the corresponding dma_alloc_coherent() call has succeeded. Calling it when the allocation fails leads to undefined behavior.
Add a check to ensure that the memory is only freed when the allocation was successful.
--- drivers/edac/altera_edac.c | 1 - 1 file changed, 1 deletion(-)
drivers/edac/altera_edac.c +0 -1
@@ -128,7 +128,6 @@ static ssize_t altr_sdr_mc_err_inject_write(struct file *file, ptemp =dma_alloc_coherent (mci->pdev,16 , &dma_handle,GFP_KERNEL );if (!ptemp) { -dma_free_coherent (mci->pdev,16 , ptemp, dma_handle);edac_printk (KERN_ERR ,EDAC_MC ,"Inject: Buffer Allocation error\n" );return -ENOMEM ;
Signature · 1 line
2.43.0
Quoted 28 lines · Salah Triki
dma_free_coherent()must only be called if the correspondingdma_alloc_coherent()call has succeeded. Calling it when the allocation fails leads to undefined behavior.Add a check to ensure that the memory is only freed when the allocation was successful.
Signed-off-by Salah Triki <[email protected]>Fixes 71bcada88b0f3 ("edac: altera: Add Altera SDRAM EDAC support")Cc Markus Elfring <[email protected]>Cc Dinh Nguyen <[email protected]>Cc Borislav Petkov <[email protected]>Cc Tony Luck <[email protected]>Cc James Morse <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Robert Richter <[email protected]>--- drivers/edac/altera_edac.c | 1 - 1 file changed, 1 deletion(-)drivers/edac/altera_edac.c +0
-0
drivers/edac/altera_edac.c static ssize_t altr_sdr_mc_err_inject_write(struct file *file, · line 133
Quoted 7 lines
drivers/edac/altera_edac.c +0
-1@@ -128,7 +128,6 @@ static ssize_t altr_sdr_mc_err_inject_write(struct file *file, ptemp =dma_alloc_coherent (mci->pdev,16 , &dma_handle,GFP_KERNEL );if (!ptemp) { -dma_free_coherent (mci->pdev,16 , ptemp, dma_handle);edac_printk (KERN_ERR ,EDAC_MC ,"Inject: Buffer Allocation error\n" );return -ENOMEM ;
…> Add a check to ensure that the memory is only freed when the allocation
Quoted 1 line
was successful.
How good does such a wording fit to the proposed function call deletion?
Regards,
Markus
Quoted 29 lines · Salah Triki
dma_free_coherent()must only be called if the correspondingdma_alloc_coherent()call has succeeded. Calling it when the allocation fails leads to undefined behavior.Add a check to ensure that the memory is only freed when the allocation was successful.
Signed-off-by Salah Triki <[email protected]>Fixes 71bcada88b0f3 ("edac: altera: Add Altera SDRAM EDAC support")Cc Markus Elfring <[email protected]>Cc Dinh Nguyen <[email protected]>Cc Borislav Petkov <[email protected]>Cc Tony Luck <[email protected]>Cc James Morse <[email protected]>Cc Mauro Carvalho Chehab <[email protected]>Cc Robert Richter <[email protected]>--- drivers/edac/altera_edac.c | 1 - 1 file changed, 1 deletion(-)drivers/edac/altera_edac.c +0
-0
drivers/edac/altera_edac.c static ssize_t altr_sdr_mc_err_inject_write(struct file *file, · line 133
Quoted 7 lines
drivers/edac/altera_edac.c +0
-1@@ -128,7 +128,6 @@ static ssize_t altr_sdr_mc_err_inject_write(struct file *file, ptemp =dma_alloc_coherent (mci->pdev,16 , &dma_handle,GFP_KERNEL );if (!ptemp) { -dma_free_coherent (mci->pdev,16 , ptemp, dma_handle);edac_printk (KERN_ERR ,EDAC_MC ,"Inject: Buffer Allocation error\n" );return -ENOMEM ;
Applied, thanks.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette