busdma: Free map, if bus_dmamap_create() fails
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Fri, 31 Dec 2010 09:43:11 +0000 (17:43 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Sat, 8 Jan 2011 15:15:35 +0000 (23:15 +0800)
sys/platform/pc32/i386/busdma_machdep.c
sys/platform/pc64/x86_64/busdma_machdep.c

index 53d1f5e..bcca769 100644 (file)
@@ -480,8 +480,12 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
        } else {
                *mapp = NULL;
        }
-       if (!error)
+       if (!error) {
                dmat->map_count++;
+       } else {
+               kfree(*mapp, M_DEVBUF);
+               *mapp = NULL;
+       }
        return error;
 }
 
index a983646..4b486c7 100644 (file)
@@ -480,8 +480,12 @@ bus_dmamap_create(bus_dma_tag_t dmat, int flags, bus_dmamap_t *mapp)
        } else {
                *mapp = NULL;
        }
-       if (!error)
+       if (!error) {
                dmat->map_count++;
+       } else {
+               kfree(*mapp, M_DEVBUF);
+               *mapp = NULL;
+       }
        return error;
 }