Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 May 2019 09:30:03 +0000 (UTC)
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r347088 - head/sys/compat/linuxkpi/common/src
Message-ID:  <201905040930.x449U39k076865@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: hselasky
Date: Sat May  4 09:30:03 2019
New Revision: 347088
URL: https://svnweb.freebsd.org/changeset/base/347088

Log:
  Fix regression issue after r346645 in the LinuxKPI.
  Properly handle error case when mapping DMA address fails.
  
  Sponsored by:		Mellanox Technologies

Modified:
  head/sys/compat/linuxkpi/common/src/linux_pci.c

Modified: head/sys/compat/linuxkpi/common/src/linux_pci.c
==============================================================================
--- head/sys/compat/linuxkpi/common/src/linux_pci.c	Sat May  4 09:28:11 2019	(r347087)
+++ head/sys/compat/linuxkpi/common/src/linux_pci.c	Sat May  4 09:30:03 2019	(r347088)
@@ -480,10 +480,15 @@ linux_dma_alloc_coherent(struct device *dev, size_t si
 	align = PAGE_SIZE << get_order(size);
 	mem = (void *)kmem_alloc_contig(size, flag, 0, high, align, 0,
 	    VM_MEMATTR_DEFAULT);
-	if (mem)
+	if (mem != NULL) {
 		*dma_handle = linux_dma_map_phys(dev, vtophys(mem), size);
-	else
+		if (*dma_handle == 0) {
+			kmem_free((vm_offset_t)mem, size);
+			mem = NULL;
+		}
+	} else {
 		*dma_handle = 0;
+	}
 	return (mem);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201905040930.x449U39k076865>