summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2005-02-24 17:58:27 +0000
committerwpaul <wpaul@FreeBSD.org>2005-02-24 17:58:27 +0000
commit6e74cf6e34565f42c3fe52a8caf126f7048941d4 (patch)
tree3ee1480dc3222ce58578974d3aa8308bbe7bae95
parent6b720fc020784b0af1438e87abde56f5ff37ae79 (diff)
downloadFreeBSD-src-6e74cf6e34565f42c3fe52a8caf126f7048941d4.zip
FreeBSD-src-6e74cf6e34565f42c3fe52a8caf126f7048941d4.tar.gz
Couple of lessons learned during USB driver testing:
- In kern_ndis.c:ndis_unload_driver(), test that ndis_block->nmb_rlist is not NULL before trying to free() it. - In subr_pe.c:pe_get_import_descriptor(), do a case-insensitive match on the import module name. Most drivers I have encountered link against "ntoskrnl.exe" but the ASIX USB ethernet driver I'm testing with wants "NTOSKRNL.EXE." - In subr_ntoskrnl.c:IoAllocateIrp(), return a pointer to the IRP instead of NULL. (Stub code leftover.) - Also in subr_ntoskrnl.c, add ExAllocatePoolWithTag() and ExFreePool() to the function table list so they'll get exported to drivers properly.
-rw-r--r--sys/compat/ndis/kern_ndis.c3
-rw-r--r--sys/compat/ndis/subr_ntoskrnl.c4
-rw-r--r--sys/compat/ndis/subr_pe.c6
3 files changed, 10 insertions, 3 deletions
diff --git a/sys/compat/ndis/kern_ndis.c b/sys/compat/ndis/kern_ndis.c
index 589742b..66c3017 100644
--- a/sys/compat/ndis/kern_ndis.c
+++ b/sys/compat/ndis/kern_ndis.c
@@ -1682,7 +1682,8 @@ ndis_unload_driver(arg)
sc = arg;
- free(sc->ndis_block->nmb_rlist, M_DEVBUF);
+ if (sc->ndis_block->nmb_rlist != NULL)
+ free(sc->ndis_block->nmb_rlist, M_DEVBUF);
ndis_flush_sysctls(sc);
diff --git a/sys/compat/ndis/subr_ntoskrnl.c b/sys/compat/ndis/subr_ntoskrnl.c
index 4065147..ed6ce41 100644
--- a/sys/compat/ndis/subr_ntoskrnl.c
+++ b/sys/compat/ndis/subr_ntoskrnl.c
@@ -722,7 +722,7 @@ IoAllocateIrp(stsize, chargequota)
IoInitializeIrp(i, IoSizeOfIrp(stsize), stsize);
- return (NULL);
+ return (i);
}
__stdcall static irp *
@@ -2615,6 +2615,8 @@ image_patch_table ntoskrnl_functbl[] = {
IMPORT_FUNC(InterlockedPushEntrySList),
IMPORT_FUNC(ExInterlockedPopEntrySList),
IMPORT_FUNC(ExInterlockedPushEntrySList),
+ IMPORT_FUNC(ExAllocatePoolWithTag),
+ IMPORT_FUNC(ExFreePool),
IMPORT_FUNC(KefAcquireSpinLockAtDpcLevel),
IMPORT_FUNC(KefReleaseSpinLockFromDpcLevel),
IMPORT_FUNC_MAP(KeAcquireSpinLockRaiseToDpc, KfAcquireSpinLock),
diff --git a/sys/compat/ndis/subr_pe.c b/sys/compat/ndis/subr_pe.c
index 5a8d897f..a3f5071 100644
--- a/sys/compat/ndis/subr_pe.c
+++ b/sys/compat/ndis/subr_pe.c
@@ -53,6 +53,8 @@ __FBSDID("$FreeBSD$");
#include <sys/errno.h>
#ifdef _KERNEL
#include <sys/systm.h>
+extern int ndis_strncasecmp(const char *, const char *, size_t);
+#define strncasecmp(a, b, c) ndis_strncasecmp(a, b, c)
#else
#include <stdio.h>
#include <stdlib.h>
@@ -431,6 +433,8 @@ pe_relocate(imgbase)
* may be linked against several modules, typically HAL.dll, ntoskrnl.exe
* and NDIS.SYS. For each module, there is a list of imported function
* names and their addresses.
+ *
+ * Note: module names are case insensitive!
*/
int
@@ -455,7 +459,7 @@ pe_get_import_descriptor(imgbase, desc, module)
while (imp_desc->iid_nameaddr) {
modname = (char *)pe_translate_addr(imgbase,
imp_desc->iid_nameaddr);
- if (!strncmp(module, modname, strlen(module))) {
+ if (!strncasecmp(module, modname, strlen(module))) {
bcopy((char *)imp_desc, (char *)desc,
sizeof(image_import_descriptor));
return(0);
OpenPOWER on IntegriCloud