From nobody Sat Jul 27 11:56:25 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WWNPk0QkXz5S6kx; Sat, 27 Jul 2024 11:56:26 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WWNPj4jfkz434b; Sat, 27 Jul 2024 11:56:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722081385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xDNZsT4du0tQaKAzB+ZvZv4C7Bv1L/otqbG5mI7Bfts=; b=alvv2XcXdzEFIC37Ky/6xLcuIQAVvm9zpM/O3CfJ7FuFLdCVJNH8zp7AP8YJ8tJB5RvhS7 o4aLs/Wm53PcI69xfwfGyxWZ7D7FCHLiNvVSOWAEgGbGJ7wQvtntCSsXv76KKuOtitvfQS pmcPg4ejLIFx3US3jxm8wSROwNEdKwJy6VU1F06jhYMHZlWj4SJsPsv39aPhe9AUdL7D/X ewbqwKjUtiR2sFFF1xscxZRNCrTTlX5nTF4LvsedxfpoBt7PBVgouV/o6o3akTWfBVaff4 ZL/AxpiPO5Ab+CAEvPk9awXt5T7ZCd59TbUVeyS2sxYbesvZfLIMTw2B2Ir/GA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722081385; a=rsa-sha256; cv=none; b=hSypjrft9UqbDpN9JXkRkBfNk4LPFheuVmnV7Wmnc20btksFdUK1VjgPE05wv+H/vW7Q1I kwdSGyg/9Q9wM4XdS1lKW3lY1fCd+VUKa+Y1hjWR6W5x0zm5mUS8eiChtgOCAYtZzHMUPy eifA/V/HJNrO6CFIQMu7W3N2bcJlOLMA5nlCI6LrzDnkRgHL62utAcM5jkm/ao7hGwaUOX 0TChKH5qXcC19GptmX8ntvVLJEvPUapmp+2JqbrePXvukpLEag4i9T/Psde4Uac1UDALVl 6Bqy2pkDSEvgFhOAh5QRrN5m/a3I4KfId2OziOvsW1Ua9Jbo479z9Y27oc+MCA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722081385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xDNZsT4du0tQaKAzB+ZvZv4C7Bv1L/otqbG5mI7Bfts=; b=OVVu27MuEWV2hZjVfOhSBQ+Cz7ru+F1YUGmwTl9e9vuPGPaxaybMAR6UK3Px3Nd9mFymFY vdy7jPKC1wnG7jK94nygZthl/WXlFJ968VV9V6IAyUkSaoyiIJrAUIuEryoRV0zss+/pw5 Slh3ECRtuw9y3iYIxN7OXxy6ws54jf9dgJJsSlycencjcCGcHdxoIDgUV9+ztCpNLwia02 c0Ohr+VVR1UH+o79GF+AtJOIFH1ArzLCBWT62IoJdHtrpI3jU/gGaqWeASWyOK2/kaXm3I Wagv5/gIPNczYvFrmeHUk7ElhO1S6hQQmZ5Dim4L4M7o+AWNxvitK0sHH+jjqQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WWNPj4DsSz15nJ; Sat, 27 Jul 2024 11:56:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46RBuPmW039949; Sat, 27 Jul 2024 11:56:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46RBuPcd039946; Sat, 27 Jul 2024 11:56:25 GMT (envelope-from git) Date: Sat, 27 Jul 2024 11:56:25 GMT Message-Id: <202407271156.46RBuPcd039946@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Christos Margiolis Subject: git: 85d1c84c2406 - main - snd_hdsp*: Free up channel resources in case of CHANNEL_INIT() failure List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 85d1c84c2406aa2e4e2114215b01eee65714848f Auto-Submitted: auto-generated The branch main has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=85d1c84c2406aa2e4e2114215b01eee65714848f commit 85d1c84c2406aa2e4e2114215b01eee65714848f Author: Christos Margiolis AuthorDate: 2024-07-27 11:55:32 +0000 Commit: Christos Margiolis CommitDate: 2024-07-27 11:55:32 +0000 snd_hdsp*: Free up channel resources in case of CHANNEL_INIT() failure Sponsored by: The FreeBSD Foundation MFC after: 2 days Reviewed by: dev_submerge.ch, markj Differential Revision: https://reviews.freebsd.org/D45982 --- sys/dev/sound/pci/hdsp-pcm.c | 59 ++++++++++++++++++++++--------------------- sys/dev/sound/pci/hdspe-pcm.c | 59 ++++++++++++++++++++++--------------------- 2 files changed, 60 insertions(+), 58 deletions(-) diff --git a/sys/dev/sound/pci/hdsp-pcm.c b/sys/dev/sound/pci/hdsp-pcm.c index 9ba0e5e345d0..29bd0bc70ee4 100644 --- a/sys/dev/sound/pci/hdsp-pcm.c +++ b/sys/dev/sound/pci/hdsp-pcm.c @@ -661,6 +661,35 @@ clean(struct sc_chinfo *ch) } /* Channel interface. */ +static int +hdspchan_free(kobj_t obj, void *data) +{ + struct sc_pcminfo *scp; + struct sc_chinfo *ch; + struct sc_info *sc; + + ch = data; + scp = ch->parent; + sc = scp->sc; + +#if 0 + device_printf(scp->dev, "hdspchan_free()\n"); +#endif + + snd_mtxlock(sc->lock); + if (ch->data != NULL) { + free(ch->data, M_HDSP); + ch->data = NULL; + } + if (ch->caps != NULL) { + free(ch->caps, M_HDSP); + ch->caps = NULL; + } + snd_mtxunlock(sc->lock); + + return (0); +} + static void * hdspchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir) @@ -720,6 +749,7 @@ hdspchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, if (sndbuf_setup(ch->buffer, ch->data, ch->size) != 0) { device_printf(scp->dev, "Can't setup sndbuf.\n"); + hdspchan_free(obj, ch); return (NULL); } @@ -793,35 +823,6 @@ hdspchan_getptr(kobj_t obj, void *data) return (pos); } -static int -hdspchan_free(kobj_t obj, void *data) -{ - struct sc_pcminfo *scp; - struct sc_chinfo *ch; - struct sc_info *sc; - - ch = data; - scp = ch->parent; - sc = scp->sc; - -#if 0 - device_printf(scp->dev, "hdspchan_free()\n"); -#endif - - snd_mtxlock(sc->lock); - if (ch->data != NULL) { - free(ch->data, M_HDSP); - ch->data = NULL; - } - if (ch->caps != NULL) { - free(ch->caps, M_HDSP); - ch->caps = NULL; - } - snd_mtxunlock(sc->lock); - - return (0); -} - static int hdspchan_setformat(kobj_t obj, void *data, uint32_t format) { diff --git a/sys/dev/sound/pci/hdspe-pcm.c b/sys/dev/sound/pci/hdspe-pcm.c index e7fa03904595..79bfcbea3406 100644 --- a/sys/dev/sound/pci/hdspe-pcm.c +++ b/sys/dev/sound/pci/hdspe-pcm.c @@ -650,6 +650,35 @@ clean(struct sc_chinfo *ch) } /* Channel interface. */ +static int +hdspechan_free(kobj_t obj, void *data) +{ + struct sc_pcminfo *scp; + struct sc_chinfo *ch; + struct sc_info *sc; + + ch = data; + scp = ch->parent; + sc = scp->sc; + +#if 0 + device_printf(scp->dev, "hdspechan_free()\n"); +#endif + + snd_mtxlock(sc->lock); + if (ch->data != NULL) { + free(ch->data, M_HDSPE); + ch->data = NULL; + } + if (ch->caps != NULL) { + free(ch->caps, M_HDSPE); + ch->caps = NULL; + } + snd_mtxunlock(sc->lock); + + return (0); +} + static void * hdspechan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, int dir) @@ -702,6 +731,7 @@ hdspechan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, if (sndbuf_setup(ch->buffer, ch->data, ch->size) != 0) { device_printf(scp->dev, "Can't setup sndbuf.\n"); + hdspechan_free(obj, ch); return (NULL); } @@ -774,35 +804,6 @@ hdspechan_getptr(kobj_t obj, void *data) return (pos); } -static int -hdspechan_free(kobj_t obj, void *data) -{ - struct sc_pcminfo *scp; - struct sc_chinfo *ch; - struct sc_info *sc; - - ch = data; - scp = ch->parent; - sc = scp->sc; - -#if 0 - device_printf(scp->dev, "hdspechan_free()\n"); -#endif - - snd_mtxlock(sc->lock); - if (ch->data != NULL) { - free(ch->data, M_HDSPE); - ch->data = NULL; - } - if (ch->caps != NULL) { - free(ch->caps, M_HDSPE); - ch->caps = NULL; - } - snd_mtxunlock(sc->lock); - - return (0); -} - static int hdspechan_setformat(kobj_t obj, void *data, uint32_t format) {