From 97dad0855d195df6d47d5e424061b44f5f981ded Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Sat, 9 Jun 2018 20:05:49 -0700 Subject: [PATCH] qcacld-3.0: Change the underlying type of mac_handle_t Currently mac_handle_t is defined as a void pointer. This is convenient from an information hiding point of view since that means a non-MAC component cannot dereference a MAC handle to access MAC private data. However this is not convenient from a defect prevention point of view since the C standard allows any other pointer type to be freely and silently converted to and from a void pointer, and hence the compiler is unable to detect when a MAC handle is used in a context where a different pointer type is expected. An example of multiple such defects was addressed by Change-Id I01812b2390269805da4d1a5cb40a811d1e22ec56 (qcacld-3.0: Fix bad pointers being passed from SME to WMA). To help prevent these kinds of defects change the definition of mac_handle_t to be a pointer to an opaque struct. Change-Id: I72483bf0e693d6eca24355f31d3a1653b8f31302 CRs-Fixed: 2268814 --- core/mac/inc/sir_types.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/mac/inc/sir_types.h b/core/mac/inc/sir_types.h index a75aafd7a848..65cd5398bed9 100644 --- a/core/mac/inc/sir_types.h +++ b/core/mac/inc/sir_types.h @@ -42,10 +42,12 @@ * pointer through this handle. */ /* - * NOTE WELL: an upcoming change will replace the void * with an - * opaque pointer just as is currently done with hdd_handle_t + * NOTE WELL: struct opaque_mac_handle is not defined anywhere. This + * reference is used to help ensure that a mac_handle_t is never used + * where a different handle type is expected */ -typedef void *mac_handle_t; +struct opaque_mac_handle; +typedef struct opaque_mac_handle *mac_handle_t; /* retain legacy name until all instances have been replaced */ typedef mac_handle_t tHalHandle;