浏览代码

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
Orhan K AKYILDIZ 8 年之前
父节点
当前提交
0f521bf9be
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      hif/src/hif_napi.c

+ 6 - 1
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) {