diff options
author | Jose Fonseca <jrfonseca@users.sourceforge.net> | 2003-06-07 12:45:55 +0000 |
---|---|---|
committer | Jose Fonseca <jrfonseca@users.sourceforge.net> | 2003-06-07 12:45:55 +0000 |
commit | 1a2bb4332972c57c0d810e879e251d74a538f13b (patch) | |
tree | 2e9326bc7136a0dc40689d1122c7f742b46dde61 | |
parent | e3a149f08095f1a7321fce890b1337098485f254 (diff) |
Verify 'drm_agp' is not NULL for all its wrappers - this causes no overhead
and must be done if in future a driver tries to talk to the AGP
directly from kernelspace instead of userspace, and the AGP is not
present.
-rw-r--r-- | linux/drm_agp_tmp.h | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/linux/drm_agp_tmp.h b/linux/drm_agp_tmp.h index 2418d791..8ae64b1d 100644 --- a/linux/drm_agp_tmp.h +++ b/linux/drm_agp_tmp.h @@ -62,6 +62,8 @@ static const drm_agp_t *drm_agp = NULL; */ int DRM(agp_acquire)(void) { + if (!drm_agp || !drm_agp->acquire) + return -EINVAL; return drm_agp->acquire(); } @@ -70,8 +72,9 @@ int DRM(agp_acquire)(void) */ void DRM(agp_release)(void) { - if (drm_agp->release) - drm_agp->release(); + if (!drm_agp || !drm_agp->release) + return; + drm_agp->release(); } /** @@ -79,8 +82,9 @@ void DRM(agp_release)(void) */ void DRM(agp_enable)(unsigned long mode) { - if (drm_agp->enable) - drm_agp->enable(mode); + if (!drm_agp || !drm_agp->enable) + return; + drm_agp->enable(mode); } /** @@ -91,7 +95,7 @@ void DRM(agp_enable)(unsigned long mode) */ agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type) { - if (!drm_agp->allocate_memory) + if (!drm_agp || !drm_agp->allocate_memory) return NULL; return drm_agp->allocate_memory(pages, type); } @@ -104,7 +108,7 @@ agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type) */ int DRM(agp_free_memory)(agp_memory *handle) { - if (!handle || !drm_agp->free_memory) + if (!handle || !drm_agp || !drm_agp->free_memory) return 0; drm_agp->free_memory(handle); return 1; @@ -118,7 +122,7 @@ int DRM(agp_free_memory)(agp_memory *handle) */ int DRM(agp_bind_memory)(agp_memory *handle, off_t start) { - if (!handle || !drm_agp->bind_memory) + if (!handle || !drm_agp || !drm_agp->bind_memory) return -EINVAL; return drm_agp->bind_memory(handle, start); } @@ -131,7 +135,7 @@ int DRM(agp_bind_memory)(agp_memory *handle, off_t start) */ int DRM(agp_unbind_memory)(agp_memory *handle) { - if (!handle || !drm_agp->unbind_memory) + if (!handle || !drm_agp || !drm_agp->unbind_memory) return -EINVAL; return drm_agp->unbind_memory(handle); } |