From owner-freebsd-bugs Wed Jul 3 11:30:11 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F04AA37B401 for ; Wed, 3 Jul 2002 11:30:03 -0700 (PDT) Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id F358243E3B for ; Wed, 3 Jul 2002 11:30:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.4/8.12.4) with ESMTP id g63IU2JU035792 for ; Wed, 3 Jul 2002 11:30:02 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.4/8.12.4/Submit) id g63IU2pJ035791; Wed, 3 Jul 2002 11:30:02 -0700 (PDT) Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9D05237B400 for ; Wed, 3 Jul 2002 11:20:48 -0700 (PDT) Received: from xkulesh.vol.cz (xkulesh.vol.cz [195.250.154.106]) by mx1.FreeBSD.org (Postfix) with ESMTP id C9E6D43E09 for ; Wed, 3 Jul 2002 11:20:45 -0700 (PDT) (envelope-from dan@obluda.cz) Received: from xkulesh.vol.cz (localhost [127.0.0.1]) by xkulesh.vol.cz (8.12.5/8.12.5) with ESMTP id g63IKSP3000343 for ; Wed, 3 Jul 2002 20:20:28 +0200 (CEST) (envelope-from dan@obluda.cz) Received: (from root@localhost) by xkulesh.vol.cz (8.12.5/8.12.2/Submit) id g638FQKX000383; Wed, 3 Jul 2002 10:15:26 +0200 (CEST) Message-Id: <200207030815.g638FQKX000383@xkulesh.vol.cz> Date: Wed, 3 Jul 2002 10:15:26 +0200 (CEST) From: Dan Lukes Reply-To: Dan Lukes To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: kern/40157: early locking in pcm/sound's pcm_chn_add() Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org >Number: 40157 >Category: kern >Synopsis: [PATCH] early locking in pcm/sound's pcm_chn_add() >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Wed Jul 03 11:30:02 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Dan Lukes >Release: FreeBSD 5.0-CURRENT i386 >Organization: >Environment: src/sys/dev/sound/pcm/sound.c,v 1.73 2002/05/19 >Description: In the code of pcm_chn_add() we obtain a lock and call sce = malloc(sizeof(*sce), M_DEVBUF, M_WAITOK | M_ZERO) there is no reason to protect initialising of sce nor calling malloc by lock on d; malloc is allowed to sleep we should avoid sleeping with locked things unless necesarry >How-To-Repeat: N/A >Fix: --- sys/dev/sound/pcm/sound.c.ORIG Sun May 19 08:31:56 2002 +++ sys/dev/sound/pcm/sound.c Wed Jul 3 09:41:36 2002 @@ -428,13 +428,12 @@ struct snddev_channel *sce, *tmp, *after; int unit = device_get_unit(d->dev); - snd_mtxlock(d->lock); - sce = malloc(sizeof(*sce), M_DEVBUF, M_WAITOK | M_ZERO); if (!sce) { - snd_mtxunlock(d->lock); return ENOMEM; } + + snd_mtxlock(d->lock); sce->channel = ch; if (SLIST_EMPTY(&d->channels)) { >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message