From owner-svn-src-head@FreeBSD.ORG Thu Oct 23 22:42:57 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 32BEA956; Thu, 23 Oct 2014 22:42:57 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 1F6A2D00; Thu, 23 Oct 2014 22:42:57 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9NMguni008310; Thu, 23 Oct 2014 22:42:56 GMT (envelope-from des@FreeBSD.org) Received: (from des@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9NMguV9008309; Thu, 23 Oct 2014 22:42:56 GMT (envelope-from des@FreeBSD.org) Message-Id: <201410232242.s9NMguV9008309@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: des set sender to des@FreeBSD.org using -f From: Dag-Erling Smørgrav Date: Thu, 23 Oct 2014 22:42:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273564 - head/sys/kern 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.18-1 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: Thu, 23 Oct 2014 22:42:57 -0000 Author: des Date: Thu Oct 23 22:42:56 2014 New Revision: 273564 URL: https://svnweb.freebsd.org/changeset/base/273564 Log: In all cases except CTLTYPE_STRING, penv is NULL here, so passing it indiscriminately to printf() and freeenv() is incorrect. Add a NULL check before freeenv(); as for printf(), we could use req.newptr instead, but we'd have to select the correct format string based on the type, and that's too much work for an error message, so just remove it. Modified: head/sys/kern/kern_sysctl.c Modified: head/sys/kern/kern_sysctl.c ============================================================================== --- head/sys/kern/kern_sysctl.c Thu Oct 23 22:33:27 2014 (r273563) +++ head/sys/kern/kern_sysctl.c Thu Oct 23 22:42:56 2014 (r273564) @@ -280,11 +280,10 @@ sysctl_load_tunable_by_oid_locked(struct } error = sysctl_root_handler_locked(oidp, oidp->oid_arg1, oidp->oid_arg2, &req); - if (error != 0) { - printf("Setting sysctl '%s' to '%s' failed: %d\n", - path, penv, error); - } - freeenv(penv); + if (error != 0) + printf("Setting sysctl %s failed: %d\n", path, error); + if (penv != NULL) + freeenv(penv); } void