From nobody Sun Nov 9 16:20:15 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551348695607752.9603573475929; Thu, 28 Feb 2019 02:11:35 -0800 (PST) Received: from localhost ([127.0.0.1]:35471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzIf3-0004Ih-A6 for importer@patchew.org; Thu, 28 Feb 2019 05:11:29 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzIco-00031o-N1 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 05:09:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzIcm-0000xC-OC for qemu-devel@nongnu.org; Thu, 28 Feb 2019 05:09:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:28472) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gzIck-0000qG-MC for qemu-devel@nongnu.org; Thu, 28 Feb 2019 05:09:08 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF696C075D75 for ; Thu, 28 Feb 2019 10:09:01 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-117-248.ams2.redhat.com [10.36.117.248]) by smtp.corp.redhat.com (Postfix) with ESMTP id 539CB5C1A1; Thu, 28 Feb 2019 10:08:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 969221750B; Thu, 28 Feb 2019 11:08:58 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Thu, 28 Feb 2019 11:08:55 +0100 Message-Id: <20190228100858.28397-3-kraxel@redhat.com> In-Reply-To: <20190228100858.28397-1-kraxel@redhat.com> References: <20190228100858.28397-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Thu, 28 Feb 2019 10:09:01 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/5] audio: Do not check for audio_calloc failure X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , Frediano Ziglio Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Frediano Ziglio audio_calloc uses g_malloc0 which never returns in case of memory failure. Signed-off-by: Frediano Ziglio Message-id: 20190225154335.11397-2-fziglio@redhat.com Signed-off-by: Gerd Hoffmann --- audio/audio.c | 48 ++++++------------------------------------------ 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/audio/audio.c b/audio/audio.c index 472721a7a9f0..909c817103c8 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -811,12 +811,7 @@ static int audio_attach_capture (HWVoiceOut *hw) SWVoiceOut *sw; HWVoiceOut *hw_cap =3D &cap->hw; =20 - sc =3D audio_calloc(__func__, 1, sizeof(*sc)); - if (!sc) { - dolog ("Could not allocate soft capture voice (%zu bytes)\n", - sizeof (*sc)); - return -1; - } + sc =3D g_malloc0(sizeof(*sc)); =20 sc->cap =3D cap; sw =3D &sc->sw; @@ -1960,15 +1955,10 @@ CaptureVoiceOut *AUD_add_capture ( if (audio_validate_settings (as)) { dolog ("Invalid settings were passed when trying to add capture\n"= ); audio_print_settings (as); - goto err0; + return NULL; } =20 - cb =3D audio_calloc(__func__, 1, sizeof(*cb)); - if (!cb) { - dolog ("Could not allocate capture callback information, size %zu\= n", - sizeof (*cb)); - goto err0; - } + cb =3D g_malloc0(sizeof(*cb)); cb->ops =3D *ops; cb->opaque =3D cb_opaque; =20 @@ -1981,12 +1971,7 @@ CaptureVoiceOut *AUD_add_capture ( HWVoiceOut *hw; CaptureVoiceOut *cap; =20 - cap =3D audio_calloc(__func__, 1, sizeof(*cap)); - if (!cap) { - dolog ("Could not allocate capture voice, size %zu\n", - sizeof (*cap)); - goto err1; - } + cap =3D g_malloc0(sizeof(*cap)); =20 hw =3D &cap->hw; QLIST_INIT (&hw->sw_head); @@ -1994,23 +1979,11 @@ CaptureVoiceOut *AUD_add_capture ( =20 /* XXX find a more elegant way */ hw->samples =3D 4096 * 4; - hw->mix_buf =3D audio_calloc(__func__, hw->samples, - sizeof(struct st_sample)); - if (!hw->mix_buf) { - dolog ("Could not allocate capture mix buffer (%d samples)\n", - hw->samples); - goto err2; - } + hw->mix_buf =3D g_new0(struct st_sample, hw->samples); =20 audio_pcm_init_info (&hw->info, as); =20 - cap->buf =3D audio_calloc(__func__, hw->samples, 1 << hw->info.shi= ft); - if (!cap->buf) { - dolog ("Could not allocate capture buffer " - "(%d samples, each %d bytes)\n", - hw->samples, 1 << hw->info.shift); - goto err3; - } + cap->buf =3D g_malloc0_n(hw->samples, 1 << hw->info.shift); =20 hw->clip =3D mixeng_clip [hw->info.nchannels =3D=3D 2] @@ -2025,15 +1998,6 @@ CaptureVoiceOut *AUD_add_capture ( audio_attach_capture (hw); } return cap; - - err3: - g_free (cap->hw.mix_buf); - err2: - g_free (cap); - err1: - g_free (cb); - err0: - return NULL; } } =20 --=20 2.9.3