浏览代码

cnss2: Add NULL check for a few exposed APIs

Per static analysis, NULL check is needed for a few exposed APIs,
hence add it.

Change-Id: I614418cd47e6cc8f7c58e294b7bd5de596b6362c
Yue Ma 3 年之前
父节点
当前提交
f6441910dc
共有 1 个文件被更改,包括 9 次插入0 次删除
  1. 9 0
      cnss2/main.c

+ 9 - 0
cnss2/main.c

@@ -324,6 +324,9 @@ int cnss_wlan_enable(struct device *dev,
 	struct cnss_plat_data *plat_priv = cnss_bus_dev_to_plat_priv(dev);
 	int ret = 0;
 
+	if (!plat_priv)
+		return -ENODEV;
+
 	if (plat_priv->device_id == QCA6174_DEVICE_ID)
 		return 0;
 
@@ -357,6 +360,9 @@ int cnss_wlan_disable(struct device *dev, enum cnss_driver_mode mode)
 	struct cnss_plat_data *plat_priv = cnss_bus_dev_to_plat_priv(dev);
 	int ret = 0;
 
+	if (!plat_priv)
+		return -ENODEV;
+
 	if (plat_priv->device_id == QCA6174_DEVICE_ID)
 		return 0;
 
@@ -432,6 +438,9 @@ int cnss_set_fw_log_mode(struct device *dev, u8 fw_log_mode)
 {
 	struct cnss_plat_data *plat_priv = cnss_bus_dev_to_plat_priv(dev);
 
+	if (!plat_priv)
+		return -ENODEV;
+
 	if (plat_priv->device_id == QCA6174_DEVICE_ID)
 		return 0;