Browse Source

qcacld-3.0: Add NULL check for return value

Currently at multiple places there is no
NULL check for return value which might
result in NULL pointer dereference.
Add NULL check for return value to avoid any
NULL pointer dereference.

Change-Id: I986a48d9649b67cb5a078ec38eea64da4ef9244e
CRs-Fixed: 3273489
Amit Mehta 2 years ago
parent
commit
cf37b0c153

+ 10 - 0
components/dp/core/inc/wlan_dp_main.h

@@ -317,6 +317,11 @@ dp_add_latency_critical_client(struct wlan_objmgr_vdev *vdev,
 {
 	struct wlan_dp_intf *dp_intf = dp_get_vdev_priv_obj(vdev);
 
+	if (!dp_intf) {
+		dp_err("Unable to get DP interface");
+		return;
+	}
+
 	switch (phymode) {
 	case QCA_WLAN_802_11_MODE_11A:
 	case QCA_WLAN_802_11_MODE_11G:
@@ -350,6 +355,11 @@ dp_del_latency_critical_client(struct wlan_objmgr_vdev *vdev,
 {
 	struct wlan_dp_intf *dp_intf = dp_get_vdev_priv_obj(vdev);
 
+	if (!dp_intf) {
+		dp_err("Unable to get DP interface");
+		return;
+	}
+
 	switch (phymode) {
 	case QCA_WLAN_802_11_MODE_11A:
 	case QCA_WLAN_802_11_MODE_11G:

+ 9 - 0
components/dp/core/src/wlan_dp_bus_bandwidth.c

@@ -2150,6 +2150,11 @@ void dp_bus_bw_compute_prev_txrx_stats(struct wlan_objmgr_vdev *vdev)
 	struct wlan_dp_intf *dp_intf = dp_get_vdev_priv_obj(vdev);
 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
 
+	if (!dp_intf) {
+		dp_err("Unable to get DP interface");
+		return;
+	}
+
 	if (QDF_GLOBAL_FTM_MODE == cds_get_conparam())
 		return;
 
@@ -2171,6 +2176,10 @@ void dp_bus_bw_compute_reset_prev_txrx_stats(struct wlan_objmgr_vdev *vdev)
 	struct wlan_dp_intf *dp_intf = dp_get_vdev_priv_obj(vdev);
 	struct wlan_dp_psoc_context *dp_ctx = dp_psoc_get_priv(psoc);
 
+	if (!dp_intf) {
+		dp_err("Unable to get DP interface");
+		return;
+	}
 	if (QDF_GLOBAL_FTM_MODE == cds_get_conparam())
 		return;
 

+ 20 - 0
components/dp/dispatcher/src/wlan_dp_ucfg_api.c

@@ -1791,6 +1791,11 @@ void ucfg_dp_set_nud_stats_cb(struct wlan_objmgr_psoc *psoc, void *cookie)
 {
 	struct wlan_dp_psoc_sb_ops *sb_ops = dp_intf_get_tx_ops(psoc);
 
+	if (!sb_ops) {
+		dp_err("Unable to get ops");
+		return;
+	}
+
 	sb_ops->dp_arp_stats_register_event_handler(psoc);
 	sb_ops->arp_request_ctx = cookie;
 }
@@ -1799,6 +1804,11 @@ void ucfg_dp_clear_nud_stats_cb(struct wlan_objmgr_psoc *psoc)
 {
 	struct wlan_dp_psoc_sb_ops *sb_ops = dp_intf_get_tx_ops(psoc);
 
+	if (!sb_ops) {
+		dp_err("Unable to get ops");
+		return;
+	}
+
 	sb_ops->dp_arp_stats_unregister_event_handler(psoc);
 }
 
@@ -1833,6 +1843,11 @@ ucfg_dp_req_get_arp_stats(struct wlan_objmgr_psoc *psoc,
 {
 	struct wlan_dp_psoc_sb_ops *sb_ops = dp_intf_get_tx_ops(psoc);
 
+	if (!sb_ops) {
+		dp_err("Unable to get ops");
+		return QDF_STATUS_E_INVAL;
+	}
+
 	return sb_ops->dp_get_arp_req_stats(psoc, params);
 }
 
@@ -1842,6 +1857,11 @@ ucfg_dp_req_set_arp_stats(struct wlan_objmgr_psoc *psoc,
 {
 	struct wlan_dp_psoc_sb_ops *sb_ops = dp_intf_get_tx_ops(psoc);
 
+	if (!sb_ops) {
+		dp_err("Unable to get ops");
+		return QDF_STATUS_E_INVAL;
+	}
+
 	return sb_ops->dp_set_arp_req_stats(psoc, params);
 }
 

+ 24 - 0
os_if/dp/src/os_if_dp.c

@@ -171,6 +171,9 @@ void osif_dp_send_tcp_param_update_event(struct wlan_objmgr_psoc *psoc,
 
 	event_len = sizeof(uint8_t) + sizeof(uint8_t) + NLMSG_HDRLEN;
 	pdev = wlan_objmgr_get_pdev_by_id(psoc, 0, WLAN_OSIF_ID);
+	if (!pdev)
+		return;
+
 	os_priv = wlan_pdev_get_ospriv(pdev);
 
 	if (dir == 0) /*TX Flow */ {
@@ -741,6 +744,11 @@ static int osif_dp_populate_dns_stats_info(struct wlan_objmgr_vdev *vdev,
 	uint32_t track_dns_domain_len;
 	struct dp_dns_stats *dns_stats = ucfg_dp_get_dns_stats(vdev);
 
+	if (!dns_stats) {
+		dp_err("Unable to get DNS stats");
+		return -EINVAL;
+	}
+
 	track_dns_domain_len = ucfg_dp_get_track_dns_domain_len_value(vdev);
 	dns_query = qdf_mem_malloc(track_dns_domain_len + 1);
 	if (!dns_query)
@@ -792,6 +800,11 @@ static int osif_dp_populate_tcp_stats_info(struct wlan_objmgr_vdev *vdev,
 	uint32_t track_dest_port = ucfg_dp_get_track_dest_port_value(vdev);
 	struct dp_tcp_stats *tcp_stats = ucfg_dp_get_tcp_stats(vdev);
 
+	if (!tcp_stats) {
+		dp_err("Unable to get TCP stats");
+		return -EINVAL;
+	}
+
 	switch (pkt_type) {
 	case CONNECTIVITY_CHECK_SET_TCP_SYN:
 		/* Fill info for tcp syn packets (tx packet) */
@@ -877,6 +890,11 @@ static int osif_dp_populate_icmpv4_stats_info(struct wlan_objmgr_vdev *vdev,
 	struct dp_icmpv4_stats *icmpv4_stats = ucfg_dp_get_icmpv4_stats(vdev);
 	uint32_t track_dest_ipv4 = ucfg_dp_get_track_dest_ipv4_value(vdev);
 
+	if (!icmpv4_stats) {
+		dp_err("Unable to get ICMP stats");
+		return -EINVAL;
+	}
+
 	if (nla_put_u16(skb, CHECK_STATS_PKT_TYPE,
 			CONNECTIVITY_CHECK_SET_ICMPV4) ||
 	    nla_put_u32(skb, CHECK_STATS_PKT_DEST_IPV4,
@@ -1059,6 +1077,12 @@ int osif_dp_get_nud_stats(struct wiphy *wiphy,
 		goto exit;
 	}
 	arp_stats = ucfg_dp_get_arp_stats(vdev);
+	if (!arp_stats) {
+		dp_err("Unable to get ARP stats");
+		err = -EINVAL;
+		goto exit;
+	}
+
 	if (nla_put_u16(skb, COUNT_FROM_NETDEV,
 			arp_stats->tx_arp_req_count) ||
 	    nla_put_u16(skb, COUNT_TO_LOWER_MAC,