svn commit: r291120 - in head/sys: arm64/arm64 x86/x86

Marius Strobl marius at FreeBSD.org
Sat Nov 21 02:08:49 UTC 2015


Author: marius
Date: Sat Nov 21 02:08:47 2015
New Revision: 291120
URL: https://svnweb.freebsd.org/changeset/base/291120

Log:
  Avoid a NULL pointer dereference in bounce_bus_dmamap_unload() when
  the map has been created via bounce_bus_dmamem_alloc(). In that case
  bus_dmamap_unload(9) typically isn't called during normal operation
  but still should be during detach, cleanup from failed attach etc.
  
  Submitted by:	yongari
  MFC after:	3 days

Modified:
  head/sys/arm64/arm64/busdma_bounce.c
  head/sys/x86/x86/busdma_bounce.c

Modified: head/sys/arm64/arm64/busdma_bounce.c
==============================================================================
--- head/sys/arm64/arm64/busdma_bounce.c	Sat Nov 21 00:35:40 2015	(r291119)
+++ head/sys/arm64/arm64/busdma_bounce.c	Sat Nov 21 02:08:47 2015	(r291120)
@@ -754,6 +754,9 @@ bounce_bus_dmamap_unload(bus_dma_tag_t d
 {
 	struct bounce_page *bpage;
 
+	if (map == NULL)
+		return;
+
 	while ((bpage = STAILQ_FIRST(&map->bpages)) != NULL) {
 		STAILQ_REMOVE_HEAD(&map->bpages, links);
 		free_bounce_page(dmat, bpage);
@@ -836,12 +839,14 @@ SYSINIT(bpages, SI_SUB_LOCK, SI_ORDER_AN
 static struct sysctl_ctx_list *
 busdma_sysctl_tree(struct bounce_zone *bz)
 {
+
 	return (&bz->sysctl_tree);
 }
 
 static struct sysctl_oid *
 busdma_sysctl_tree_top(struct bounce_zone *bz)
 {
+
 	return (bz->sysctl_tree_top);
 }
 

Modified: head/sys/x86/x86/busdma_bounce.c
==============================================================================
--- head/sys/x86/x86/busdma_bounce.c	Sat Nov 21 00:35:40 2015	(r291119)
+++ head/sys/x86/x86/busdma_bounce.c	Sat Nov 21 02:08:47 2015	(r291120)
@@ -878,6 +878,9 @@ bounce_bus_dmamap_unload(bus_dma_tag_t d
 {
 	struct bounce_page *bpage;
 
+	if (map == NULL)
+		return;
+
 	while ((bpage = STAILQ_FIRST(&map->bpages)) != NULL) {
 		STAILQ_REMOVE_HEAD(&map->bpages, links);
 		free_bounce_page(dmat, bpage);
@@ -1000,12 +1003,14 @@ SYSINIT(bpages, SI_SUB_LOCK, SI_ORDER_AN
 static struct sysctl_ctx_list *
 busdma_sysctl_tree(struct bounce_zone *bz)
 {
+
 	return (&bz->sysctl_tree);
 }
 
 static struct sysctl_oid *
 busdma_sysctl_tree_top(struct bounce_zone *bz)
 {
+
 	return (bz->sysctl_tree_top);
 }
 


More information about the svn-src-all mailing list