Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Jun 2017 22:17:55 +0000 (UTC)
From:      "Stephen J. Kiernan" <stevek@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r319639 - head/usr.sbin/bluetooth/hccontrol
Message-ID:  <201706062217.v56MHtDa032755@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: stevek
Date: Tue Jun  6 22:17:55 2017
New Revision: 319639
URL: https://svnweb.freebsd.org/changeset/base/319639

Log:
  When the input parameter node is NULL, memory is allocated to it.
  To later free the memory, introduce a new variable lnode to track when
  this happens.
  
  Submitted by:	Thomas Rix <trix@juniper.net>
  Reviewed by:	emax
  Approved by:	sjg (mentor)
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D9878

Modified:
  head/usr.sbin/bluetooth/hccontrol/hccontrol.c

Modified: head/usr.sbin/bluetooth/hccontrol/hccontrol.c
==============================================================================
--- head/usr.sbin/bluetooth/hccontrol/hccontrol.c	Tue Jun  6 21:51:04 2017	(r319638)
+++ head/usr.sbin/bluetooth/hccontrol/hccontrol.c	Tue Jun  6 22:17:55 2017	(r319639)
@@ -103,13 +103,14 @@ socket_open(char const *node)
 	int					 s, mib[4], num;
 	size_t					 size;
 	struct nodeinfo 			*nodes;
+	char                                    *lnode = NULL;
 
 	num = find_hci_nodes(&nodes);
 	if (num == 0)
 		errx(7, "Could not find HCI nodes");
 
 	if (node == NULL) {
-		node = strdup(nodes[0].name);
+		node = lnode = strdup(nodes[0].name);
 		if (num > 1)
 			fprintf(stdout, "Using HCI node: %s\n", node);
 	}
@@ -130,6 +131,7 @@ socket_open(char const *node)
 	if (connect(s, (struct sockaddr *) &addr, sizeof(addr)) < 0)
 		err(3, "Could not connect socket, node=%s", node);
 
+	free(lnode);
 	memset(&filter, 0, sizeof(filter));
 	bit_set(filter.event_mask, NG_HCI_EVENT_COMMAND_COMPL - 1);
 	bit_set(filter.event_mask, NG_HCI_EVENT_COMMAND_STATUS - 1);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706062217.v56MHtDa032755>