From b3853a6bce5868f5aa63c916e63c21bd25a8dba4 Mon Sep 17 00:00:00 2001 From: Owain Ainsworth Date: Wed, 15 Apr 2009 02:03:34 +0000 Subject: make load_raw do the same as the others and set mapsize and nsegs to zero so that we return an empty map on error. --- sys/arch/amd64/amd64/bus_dma.c | 8 +++++++- sys/arch/i386/i386/bus_dma.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/amd64/amd64/bus_dma.c b/sys/arch/amd64/amd64/bus_dma.c index eb906a4cea5..6f2eb97d7a5 100644 --- a/sys/arch/amd64/amd64/bus_dma.c +++ b/sys/arch/amd64/amd64/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.23 2009/04/15 01:58:27 oga Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.24 2009/04/15 02:03:33 oga Exp $ */ /* $NetBSD: bus_dma.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */ /*- @@ -313,6 +313,12 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs, int first = 1; int i, seg = 0; + /* + * Make sure that on error condition we return "no valid mappings". + */ + map->dm_mapsize = 0; + map->dm_nsegs = 0; + if (nsegs > map->_dm_segcnt || size > map->_dm_size) return (EINVAL); diff --git a/sys/arch/i386/i386/bus_dma.c b/sys/arch/i386/i386/bus_dma.c index 8de38929bd3..59cf6082ef7 100644 --- a/sys/arch/i386/i386/bus_dma.c +++ b/sys/arch/i386/i386/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.13 2009/04/15 01:58:27 oga Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.14 2009/04/15 02:03:33 oga Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. * All rights reserved. @@ -280,6 +280,12 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs, int first = 1; int i, seg = 0; + /* + * Make sure that on error condition we return "no valid mappings". + */ + map->dm_mapsize = 0; + map->dm_nsegs = 0; + if (nsegs > map->_dm_segcnt || size > map->_dm_size) return (EINVAL); -- cgit v1.2.3