From owner-svn-src-head@FreeBSD.ORG Sat Feb 11 04:12:12 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7EF6A106566C; Sat, 11 Feb 2012 04:12:12 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6E15D8FC08; Sat, 11 Feb 2012 04:12:12 +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 q1B4CC3g012557; Sat, 11 Feb 2012 04:12:12 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1B4CCYf012555; Sat, 11 Feb 2012 04:12:12 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201202110412.q1B4CCYf012555@svn.freebsd.org> From: David Xu Date: Sat, 11 Feb 2012 04:12:12 +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: r231503 - head/lib/libthr/thread X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Sat, 11 Feb 2012 04:12:12 -0000 Author: davidxu Date: Sat Feb 11 04:12:12 2012 New Revision: 231503 URL: http://svn.freebsd.org/changeset/base/231503 Log: Make code more stable by checking NULL pointers. Modified: head/lib/libthr/thread/thr_list.c Modified: head/lib/libthr/thread/thr_list.c ============================================================================== --- head/lib/libthr/thread/thr_list.c Sat Feb 11 01:17:27 2012 (r231502) +++ head/lib/libthr/thread/thr_list.c Sat Feb 11 04:12:12 2012 (r231503) @@ -154,8 +154,12 @@ _thr_alloc(struct pthread *curthread) atomic_fetchadd_int(&total_threads, -1); return (NULL); } - thread->sleepqueue = _sleepq_alloc(); - thread->wake_addr = _thr_alloc_wake_addr(); + if ((thread->sleepqueue = _sleepq_alloc()) == NULL || + (thread->wake_addr = _thr_alloc_wake_addr()) == NULL) { + thr_destroy(curthread, thread); + atomic_fetchadd_int(&total_threads, -1); + return (NULL); + } } else { bzero(&thread->_pthread_startzero, __rangeof(struct pthread, _pthread_startzero, _pthread_endzero));