From 0f521bf9be3bda79c9f16e8242771bd8940a74d7 Mon Sep 17 00:00:00 2001 From: Orhan K AKYILDIZ Date: Tue, 29 Nov 2016 19:30:04 -0800 Subject: [PATCH] qcacmn: Harden NAPI event handler Make sure that NAPI event handler would handle events only after it has been initialized. Check init flag before procesing the event and emit a warning and return an error to the caller. Change-Id: I9d2b84560ee2363ecf2a570dbef0275dfb87786a CRs-Fixed: 1091678 --- hif/src/hif_napi.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hif/src/hif_napi.c b/hif/src/hif_napi.c index 7ac3480bb9..e0c5c7e8c3 100644 --- a/hif/src/hif_napi.c +++ b/hif/src/hif_napi.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016 The Linux Foundation. All rights reserved. + * Copyright (c) 2015-2017 The Linux Foundation. All rights reserved. * * Previously licensed under the ISC license by Qualcomm Atheros, Inc. * @@ -468,6 +468,11 @@ int hif_napi_event(struct hif_opaque_softc *hif_ctx, enum qca_napi_event event, NAPI_DEBUG("%s: -->(event=%d, aux=%p)", __func__, event, data); + if ((napid->state & HIF_NAPI_INITED) == 0) { + NAPI_DEBUG("%s: got event when NAPI not initialized", + __func__); + return -EINVAL; + } spin_lock_bh(&(napid->lock)); prev_state = napid->state; switch (event) {