Page MenuHomeFreeBSD

D42723.id130439.diff
No OneTemporary

D42723.id130439.diff

diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -2715,6 +2715,37 @@
args->memattr = VM_MEMATTR_DEVICE;
}
+int
+resource_validate_map_request(struct resource *r,
+ struct resource_map_request *in, struct resource_map_request *out,
+ rman_res_t *startp, rman_res_t *lengthp)
+{
+ rman_res_t end, length, start;
+
+ /*
+ * This assumes that any callers of this function are compiled
+ * into the kernel and use the same version of the structure
+ * as this file.
+ */
+ MPASS(out->size == sizeof(struct resource_map_request));
+
+ if (in != NULL)
+ bcopy(in, out, imin(in->size, out->size));
+ start = rman_get_start(r) + out->offset;
+ if (out->length == 0)
+ length = rman_get_size(r);
+ else
+ length = out->length;
+ end = start + length - 1;
+ if (start > rman_get_end(r) || start < rman_get_start(r))
+ return (EINVAL);
+ if (end > rman_get_end(r) || end < start)
+ return (EINVAL);
+ *lengthp = length;
+ *startp = start;
+ return (0);
+}
+
/**
* @brief Initialise a resource list.
*
diff --git a/sys/sys/bus.h b/sys/sys/bus.h
--- a/sys/sys/bus.h
+++ b/sys/sys/bus.h
@@ -317,6 +317,8 @@
KOBJ_CLASS_FIELDS;
};
+struct resource;
+
/**
* @brief A resource mapping.
*/
@@ -341,12 +343,14 @@
size_t _sz);
#define resource_init_map_request(rmr) \
resource_init_map_request_impl((rmr), sizeof(*(rmr)))
+int resource_validate_map_request(struct resource *r,
+ struct resource_map_request *in, struct resource_map_request *out,
+ rman_res_t *startp, rman_res_t *lengthp);
/*
* Definitions for drivers which need to keep simple lists of resources
* for their child devices.
*/
-struct resource;
/**
* @brief An entry for a single resource in a resource list.

File Metadata

Mime Type
text/plain
Expires
Mon, Feb 9, 3:47 AM (13 h, 19 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28511392
Default Alt Text
D42723.id130439.diff (1 KB)

Event Timeline