Add some bulletproofing: don't allow the ndis_get_info() or ndis_set_info()

routines to do anything except return error if the miniport adapter context
is not set (meaning we either having init'ed the driver yet, or the
initialization failed).

Also, be sure to NULL out the adapter context along with the
miniport characteristics pointers if calling the MiniportInitialize()
method fails.
This commit is contained in:
Bill Paul 2004-02-10 23:01:53 +00:00
parent 3a53156b9b
commit eae7237c29

View File

@ -991,6 +991,9 @@ ndis_set_info(arg, oid, buf, buflen)
setfunc = sc->ndis_chars.nmc_setinfo_func;
adapter = sc->ndis_block.nmb_miniportadapterctx;
if (adapter == NULL)
return(ENXIO);
rval = setfunc(adapter, oid, buf, *buflen,
&byteswritten, &bytesneeded);
@ -1272,6 +1275,7 @@ ndis_init_nic(arg)
if (status != NDIS_STATUS_SUCCESS) {
bzero((char *)&sc->ndis_chars,
sizeof(ndis_miniport_characteristics));
sc->ndis_block.nmb_miniportadapterctx = NULL;
return(ENXIO);
}
@ -1380,6 +1384,9 @@ ndis_get_info(arg, oid, buf, buflen)
queryfunc = sc->ndis_chars.nmc_queryinfo_func;
adapter = sc->ndis_block.nmb_miniportadapterctx;
if (adapter == NULL)
return(ENXIO);
rval = queryfunc(adapter, oid, buf, *buflen,
&byteswritten, &bytesneeded);