From f8406bf8c9f9eda64d122c2b5d51f5fecfff141a Mon Sep 17 00:00:00 2001 From: Jeff Johnson Date: Sun, 3 Jun 2018 08:31:46 -0700 Subject: [PATCH] qcacld-3.0: Change the underlying type of hdd_handle_t Currently hdd_handle_t is defined as a void pointer. This is convenient from an information hiding point of view since that means a non-HDD component cannot dereference an HDD handle to access HDD 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 an HDD handle is used in a context where a different pointer type is expected. An example of one such defect was addressed by Change-Id I2bbf1bf4a7975e5cb44066b6a3b1a98e82df9fad (qcacld-3.0: Fix bad param passed during QoS Map conversion). To help prevent this kind of defect change the definition of hdd_handle_t to be a pointer to an opaque struct. Change-Id: I6e885f84c0554bbe5c8582474fddb65ab6a0fdac CRs-Fixed: 2254907 --- core/mac/inc/sir_types.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core/mac/inc/sir_types.h b/core/mac/inc/sir_types.h index af075965e8..349ba44aae 100644 --- a/core/mac/inc/sir_types.h +++ b/core/mac/inc/sir_types.h @@ -51,7 +51,13 @@ typedef void *tHalHandle; * The HDD must be able to derive it's internal instance structure * pointer through this handle. */ -typedef void *hdd_handle_t; +/* + * NOTE WELL: struct opaque_hdd_handle is not defined anywhere. This + * reference is used to help ensure that a hdd_handle_t is never used + * where a different handle type is expected + */ +struct opaque_hdd_handle; +typedef struct opaque_hdd_handle *hdd_handle_t; /* ********************************************** * * *