gfx: pvr: Dereference a pointer after null check
authorPauli Nieminen <pauli.nieminen@linux.intel.com>
Mon, 2 Jan 2012 14:24:30 +0000 (16:24 +0200)
committerMarkus Lehtonen <markus.lehtonen@linux.intel.com>
Tue, 3 Jul 2012 09:29:22 +0000 (12:29 +0300)
Dereferencing a pointer may only happen after NULL check to avoid crash
if the pointer is NULL.

[pvr/services4/srvkm/common/buffer_manager.c:1152]: (error) Possible
null pointer dereference: psBMHeap - otherwise it is redundant to check
if psBMHeap is null at line 1156

Reported-by: Olev Kartau <olev.kartau@intel.com>
Signed-off-by: Pauli Nieminen <pauli.nieminen@linux.intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
drivers/staging/mrst/pvr/services4/srvkm/common/buffer_manager.c

index 456e44e..326e958 100644 (file)
@@ -1149,12 +1149,13 @@ IMG_VOID
 BM_DestroyHeap (IMG_HANDLE hDevMemHeap)
 {
        BM_HEAP* psBMHeap = (BM_HEAP*)hDevMemHeap;
-       PVRSRV_DEVICE_NODE *psDeviceNode = psBMHeap->pBMContext->psDeviceNode;
+       PVRSRV_DEVICE_NODE *psDeviceNode;
 
        PVR_DPF((PVR_DBG_MESSAGE, "BM_DestroyHeap"));
 
        if(psBMHeap)
        {
+               psDeviceNode = psBMHeap->pBMContext->psDeviceNode;
                
                if(psBMHeap->ui32Attribs
                &       (PVRSRV_BACKINGSTORE_SYSMEM_NONCONTIG