浏览代码

icnss2: Add null check for priv variable

Add null check for priv variable to avoid null
pointer dereference.

Change-Id: Ib1746d564f27f8096f66761946d37a2a3faf2e57
CRs-Fixed: 3378034
Sandeep Singh 2 年之前
父节点
当前提交
ecd2be21ed
共有 1 个文件被更改,包括 11 次插入5 次删除
  1. 11 5
      icnss2/main.c

+ 11 - 5
icnss2/main.c

@@ -152,6 +152,9 @@ static ssize_t icnss_sysfs_store(struct kobject *kobj,
 {
 	struct icnss_priv *priv = icnss_get_plat_priv();
 
+	if (!priv)
+		return count;
+
 	icnss_pr_dbg("Received shutdown indication");
 
 	atomic_set(&priv->is_shutdown, true);
@@ -466,7 +469,7 @@ static int icnss_send_smp2p(struct icnss_priv *priv,
 	unsigned int value = 0;
 	int ret;
 
-	if (IS_ERR(priv->smp2p_info[smp2p_entry].smem_state))
+	if (!priv || IS_ERR(priv->smp2p_info[smp2p_entry].smem_state))
 		return -EINVAL;
 
 	/* No Need to check FW_DOWN for ICNSS_RESET_MSG */
@@ -547,11 +550,11 @@ static irqreturn_t fw_crash_indication_handler(int irq, void *ctx)
 
 	icnss_pr_err("Received early crash indication from FW\n");
 
-	if (priv->wpss_self_recovery_enabled)
-		mod_timer(&priv->wpss_ssr_timer,
-			  jiffies + msecs_to_jiffies(ICNSS_WPSS_SSR_TIMEOUT));
-
 	if (priv) {
+		if (priv->wpss_self_recovery_enabled)
+			mod_timer(&priv->wpss_ssr_timer,
+				  jiffies + msecs_to_jiffies(ICNSS_WPSS_SSR_TIMEOUT));
+
 		set_bit(ICNSS_FW_DOWN, &priv->state);
 		icnss_ignore_fw_timeout(true);
 
@@ -2426,6 +2429,9 @@ static void icnss_pdr_notifier_cb(int state, char *service_path, void *priv_cb)
 	struct icnss_uevent_fw_down_data fw_down_data = {0};
 	enum icnss_pdr_cause_index cause = ICNSS_ROOT_PD_CRASH;
 
+	if (!priv)
+		return;
+
 	icnss_pr_dbg("PD service notification: 0x%lx state: 0x%lx\n",
 		     state, priv->state);