From owner-svn-src-all@FreeBSD.ORG Sat Oct 6 20:16:04 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id A29A71065670; Sat, 6 Oct 2012 20:16:04 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 8CC638FC17; Sat, 6 Oct 2012 20:16:04 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q96KG4a1033182; Sat, 6 Oct 2012 20:16:04 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q96KG41g033180; Sat, 6 Oct 2012 20:16:04 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201210062016.q96KG41g033180@svn.freebsd.org> From: Andriy Gapon Date: Sat, 6 Oct 2012 20:16:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r241303 - head/lib/libkvm X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 Oct 2012 20:16:04 -0000 Author: avg Date: Sat Oct 6 20:16:04 2012 New Revision: 241303 URL: http://svn.freebsd.org/changeset/base/241303 Log: kvm_getprocs: gracefully handle errors from kvm_deadprocs and don't confuse callers with incorrect return value MFC after: 9 days Modified: head/lib/libkvm/kvm_proc.c Modified: head/lib/libkvm/kvm_proc.c ============================================================================== --- head/lib/libkvm/kvm_proc.c Sat Oct 6 20:12:24 2012 (r241302) +++ head/lib/libkvm/kvm_proc.c Sat Oct 6 20:16:04 2012 (r241303) @@ -593,9 +593,15 @@ liveout: nprocs = kvm_deadprocs(kd, op, arg, nl[1].n_value, nl[2].n_value, nprocs); + if (nprocs <= 0) { + _kvm_freeprocs(kd); + nprocs = 0; + } #ifdef notdef - size = nprocs * sizeof(struct kinfo_proc); - (void)realloc(kd->procbase, size); + else { + size = nprocs * sizeof(struct kinfo_proc); + kd->procbase = realloc(kd->procbase, size); + } #endif } *cnt = nprocs;