vxge: fix return of a free’d memblock on a failed dma mapping [Linux 3.16.72]

This Linux kernel change "vxge: fix return of a free’d memblock on a failed dma mapping" is included in the Linux 3.16.72 release. This change is authored by Colin Ian King <colin.king [at] canonical.com> on Fri Apr 12 14:45:12 2019 +0100. The commit for this change in Linux stable tree is e10ea2d (patch) which is from upstream commit 0a2c34f. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 0a2c34f.

vxge: fix return of a free'd memblock on a failed dma mapping

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@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>

There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/net/ethernet/neterion/vxge/vxge-config.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
index 4332ebb..39f4b38 100644
--- 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(struct __vxge_hw_device *devh, u32 size,
            vxge_os_dma_free(devh->pdev, memblock,
            status = VXGE_HW_ERR_OUT_OF_MEMORY;
+           memblock = NULL;
            goto exit;

Leave a Reply

Your email address will not be published. Required fields are marked *