[PATCH 3.16 082/157] vxge: fix return of a free'd memblock on a failed dma mapping
From: Ben Hutchings
Date: Sat Aug 10 2019 - 16:47:10 EST
3.16.72-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
commit 0a2c34f18c94b596562bf3d019fceab998b8b584 upstream.
Currently if a pci dma mapping failure is detected a free'd
memblock address is returned rather than a NULL (that indicates
an error). Fix this by ensuring NULL is returned on this error case.
Addresses-Coverity: ("Use after free")
Fixes: 528f727279ae ("vxge: code cleanup and reorganization")
Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@xxxxxxxxxxxxxxx>
---
drivers/net/ethernet/neterion/vxge/vxge-config.c | 1 +
1 file changed, 1 insertion(+)
--- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
+++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
@@ -2381,6 +2381,7 @@ static void *__vxge_hw_blockpool_malloc(
vxge_os_dma_free(devh->pdev, memblock,
&dma_object->acc_handle);
status = VXGE_HW_ERR_OUT_OF_MEMORY;
+ memblock = NULL;
goto exit;
}