Browse Source

qcacld-3.0: Check pointers for NULL before use

Some pointers returned from functions may be NULL, so fix these
issues to aviod some null pointer usage.

Change-Id: Ic2e801013d9edf1442b1317fe82718d2e89f9210
CRs-Fixed: 2772605
Guisen Yang 4 years ago
parent
commit
c169b214f9
1 changed files with 18 additions and 6 deletions
  1. 18 6
      core/dp/txrx/ol_txrx.c

+ 18 - 6
core/dp/txrx/ol_txrx.c

@@ -5163,11 +5163,17 @@ static QDF_STATUS ol_txrx_register_peer(struct ol_txrx_desc_type *sta_desc)
 {
 	struct ol_txrx_peer_t *peer;
 	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
-	ol_txrx_pdev_handle pdev =
-		ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
+	ol_txrx_pdev_handle pdev;
 	union ol_txrx_peer_update_param_t param;
 	struct privacy_exemption privacy_filter;
 
+	if (!soc) {
+		ol_txrx_err("Soc is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
+
 	if (!pdev) {
 		ol_txrx_err("Pdev is NULL");
 		return QDF_STATUS_E_INVAL;
@@ -5208,12 +5214,18 @@ static QDF_STATUS ol_txrx_register_peer(struct ol_txrx_desc_type *sta_desc)
 static QDF_STATUS ol_txrx_register_ocb_peer(uint8_t *mac_addr)
 {
 	struct ol_txrx_soc_t *soc = cds_get_context(QDF_MODULE_ID_SOC);
-	ol_txrx_pdev_handle pdev =
-		ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
+	ol_txrx_pdev_handle pdev;
 	ol_txrx_peer_handle peer;
 
-	if (!pdev || !soc) {
-		ol_txrx_err("Unable to find pdev or soc!");
+	if (!soc) {
+		ol_txrx_err("Unable to find soc!");
+		return QDF_STATUS_E_FAILURE;
+	}
+
+	pdev = ol_txrx_get_pdev_from_pdev_id(soc, OL_TXRX_PDEV_ID);
+
+	if (!pdev) {
+		ol_txrx_err("Unable to find pdev!");
 		return QDF_STATUS_E_FAILURE;
 	}