From owner-svn-src-head@freebsd.org Tue Jun 6 22:17:57 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 27551BF5FA5; Tue, 6 Jun 2017 22:17:57 +0000 (UTC) (envelope-from stevek@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5300C7D08A; Tue, 6 Jun 2017 22:17:56 +0000 (UTC) (envelope-from stevek@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v56MHtsm032756; Tue, 6 Jun 2017 22:17:55 GMT (envelope-from stevek@FreeBSD.org) Received: (from stevek@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v56MHtDa032755; Tue, 6 Jun 2017 22:17:55 GMT (envelope-from stevek@FreeBSD.org) Message-Id: <201706062217.v56MHtDa032755@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: stevek set sender to stevek@FreeBSD.org using -f From: "Stephen J. Kiernan" Date: Tue, 6 Jun 2017 22:17:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r319639 - head/usr.sbin/bluetooth/hccontrol X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Jun 2017 22:17:57 -0000 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 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);