API needs to check KObject types
The Issue
Currently, only some API calls check to see if accepted KObjects are the correct type. Although all API's check for this through an assert(), this will do absolutely nothing when built in Release mode. Consequently, if a user were to pass the wrong type of KObject (let's face it, this could certainly happen since they are generic) then the subsequent call to container_of() would result in very bad things going down.
The Solution
All API calls accepting KObject types must:
- Check if each
KObjectisNULL. If so, returnNULL_INPUTif the return type isKErrorCode - Check if each
KObjecthas the expectedKObjectType(viakobject_type()). If not, returnWRONG_KOBJECT_TYPEif the return type isKErrorCode