Browse Source

qcacmn: Fix wlan log svc leaks

There is a memory leak within wlan logging thread.

To address this issue free the memory at appropriate places.

Change-Id: I41c7756d6547c0bfa783a48ebc31c9f1ef0df5db
CRs-Fixed: 2011525
Ashish Kumar Dhanotiya 8 years ago
parent
commit
55e1d72428
2 changed files with 36 additions and 21 deletions
  1. 0 4
      utils/logging/src/wlan_logging_sock_svc.c
  2. 36 17
      utils/nlink/src/wlan_nlink_srv.c

+ 0 - 4
utils/logging/src/wlan_logging_sock_svc.c

@@ -667,10 +667,6 @@ static int send_filled_buffers_to_user(void)
 		if (ret < 0 && (!(gwlan_logging.drop_count % 0x40))) {
 			pr_err("%s: Send Failed %d drop_count = %u\n",
 			       __func__, ret, ++gwlan_logging.drop_count);
-			skb = NULL;
-		} else {
-			skb = NULL;
-			ret = 0;
 		}
 	}
 

+ 36 - 17
utils/nlink/src/wlan_nlink_srv.c

@@ -138,8 +138,15 @@ int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag)
 	/* not multicast */
 	NETLINK_CB(skb).dst_group = 0;
 
-	if (nl_srv_is_initialized() == 0)
+	if (nl_srv_is_initialized() == 0) {
 		err = cnss_logger_nl_ucast(skb, dst_pid, flag);
+		if (err < 0) {
+			QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_WARN,
+				  "NLINK: netlink_unicast to pid[%d] failed, ret[%d]",
+				  dst_pid, err);
+			dev_kfree_skb(skb);
+		}
+	}
 	else
 		dev_kfree_skb(skb);
 	return err;
@@ -170,8 +177,15 @@ int nl_srv_bcast(struct sk_buff *skb)
 	 /* destination group */
 	NETLINK_CB(skb).dst_group = WLAN_NLINK_MCAST_GRP_ID;
 
-	if (nl_srv_is_initialized() == 0)
+	if (nl_srv_is_initialized() == 0) {
 		err = cnss_logger_nl_bcast(skb, WLAN_NLINK_MCAST_GRP_ID, flags);
+		if ((err < 0) && (err != -ESRCH)) {
+			QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_WARN,
+				  "NLINK: netlink_broadcast failed err = %d",
+				   err);
+			dev_kfree_skb(skb);
+		}
+	}
 	else
 		dev_kfree_skb(skb);
 	return err;
@@ -350,19 +364,21 @@ int nl_srv_unregister(tWlanNlModTypes msg_type, nl_srv_msg_callback msg_handler)
  */
 int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag)
 {
-	int err = 0;
+	int err = -EINVAL;
 
 	NETLINK_CB(skb).portid = 0;     /* sender's pid */
 	NETLINK_CB(skb).dst_group = 0;  /* not multicast */
 
-	if (nl_srv_sock)
+	if (nl_srv_sock) {
 		err = netlink_unicast(nl_srv_sock, skb, dst_pid, flag);
-
-	if (err < 0)
-		QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_WARN,
-			  "NLINK: netlink_unicast to pid[%d] failed, ret[%d]",
-			  dst_pid, err);
-
+		if (err < 0) {
+			QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_WARN,
+				  "NLINK: netlink_unicast to pid[%d] failed, ret[%d]",
+				  dst_pid, err);
+			dev_kfree_skb(skb);
+		}
+	} else
+		dev_kfree_skb(skb);
 	return err;
 }
 
@@ -372,7 +388,7 @@ int nl_srv_ucast(struct sk_buff *skb, int dst_pid, int flag)
  */
 int nl_srv_bcast(struct sk_buff *skb)
 {
-	int err = 0;
+	int err = -EINVAL;
 	int flags = GFP_KERNEL;
 
 	if (in_interrupt() || irqs_disabled() || in_atomic())
@@ -381,14 +397,17 @@ int nl_srv_bcast(struct sk_buff *skb)
 	NETLINK_CB(skb).portid = 0;     /* sender's pid */
 	NETLINK_CB(skb).dst_group = WLAN_NLINK_MCAST_GRP_ID;    /* destination group */
 
-	if (nl_srv_sock)
+	if (nl_srv_sock) {
 		err = netlink_broadcast(nl_srv_sock, skb, 0,
 					WLAN_NLINK_MCAST_GRP_ID, flags);
-
-	if ((err < 0) && (err != -ESRCH)) {
-		QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_WARN,
-			  "NLINK: netlink_broadcast failed err = %d", err);
-	}
+		if ((err < 0) && (err != -ESRCH)) {
+			QDF_TRACE(QDF_MODULE_ID_HDD, QDF_TRACE_LEVEL_WARN,
+				  "NLINK: netlink_broadcast failed err = %d",
+				   err);
+			dev_kfree_skb(skb);
+		}
+	} else
+		dev_kfree_skb(skb);
 	return err;
 }