i40iw: Do not set self-referencing pointer to NULL after kfree
authorMustafa Ismail <mustafa.ismail@intel.com>
Tue, 23 Aug 2016 00:01:47 +0000 (19:01 -0500)
committerDoug Ledford <dledford@redhat.com>
Wed, 24 Aug 2016 15:25:34 +0000 (11:25 -0400)
In i40iw_free_virt_mem(), do not set mem->va to NULL
after freeing it as mem->va is a self-referencing pointer
to mem.

Fixes: 4e9042e647ff ("i40iw: add hw and utils files")

Reported-by: Stefan Assmann <sassmann@redhat.com>
Signed-off-by: Mustafa Ismail <mustafa.ismail@intel.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/i40iw/i40iw_utils.c

index 0e8db0a3514153d7659977ff31d4dbaf45a103d5..6fd043b1d71413fbcebe8a209121a9cee50a5586 100644 (file)
@@ -673,8 +673,11 @@ enum i40iw_status_code i40iw_free_virt_mem(struct i40iw_hw *hw,
 {
        if (!mem)
                return I40IW_ERR_PARAM;
+       /*
+        * mem->va points to the parent of mem, so both mem and mem->va
+        * can not be touched once mem->va is freed
+        */
        kfree(mem->va);
-       mem->va = NULL;
        return 0;
 }