From nobody Mon Feb 9 17:36:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620398659; cv=none; d=zohomail.com; s=zohoarc; b=lZoHcwOzE9Hx1B+aYxSWwBMJOKtqHfXZvW5veunqlYtqSpoTucOIyiwx+gBgINN6370HnkPYcu+s4OKCj1GPiZMCLXHyw09kyhf6zNtNiinRlgunE2zncfYl43kPYR1BZqjMf+STqhXF71JI6/32+GBmmgfnHYE/0HwnT/keT6M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398659; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=LTsvX/otw5M7TG+3dUKEvSePlS48V26N+Mr55ie/fDA=; b=iyBS98jkkxiO5NSFwdBXE10Jx9Di7OtFYr47627Go0YIlEr/A/vD3ykm2SYMNaSfCeUSg1YgtVs1G6vEIfSpwiyILCcRWgf52RGnoh25TUG0UTco3Ycr4yktNat0O5VR8Fe6QhAQygk48XhRi/tehDzBtKj8yBgEtaUVTKKqJB8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1620398659788708.9202484410638; Fri, 7 May 2021 07:44:19 -0700 (PDT) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-535-0XkjKfiWNKqOtLuGXvk7uQ-1; Fri, 07 May 2021 10:44:11 -0400 Received: by mail-wr1-f70.google.com with SMTP id 93-20020adf93e60000b029010d9bb1923eso3695438wrp.4 for ; Fri, 07 May 2021 07:44:11 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (astrasbourg-652-1-219-60.w90-40.abo.wanadoo.fr. [90.40.114.60]) by smtp.gmail.com with ESMTPSA id w25sm6720771wmk.39.2021.05.07.07.44.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398658; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LTsvX/otw5M7TG+3dUKEvSePlS48V26N+Mr55ie/fDA=; b=W8vdty0G7co2nVEPWyMT8PZLlJt3W/57AV/bxxAh4t2/IuLBeOWS2tmdeDZcCYtq+Dc+pe IB7QiHqaPkONfnVcJVLTEvPiLcxpEjmL65blCxpmA68QOnkvYe73hSlNtji55NiuCx9hdW nlIqK/R0EBjKhl/OX7G9nsJWgh6EVbw= X-MC-Unique: 0XkjKfiWNKqOtLuGXvk7uQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=LTsvX/otw5M7TG+3dUKEvSePlS48V26N+Mr55ie/fDA=; b=WwE/2tLEmCKwUPwlA5LIpFSflJ2ILDZkI09TUhxGzyIt5/2YPQByFdf4WSPhguFKGD fnY23m/xOq9GM4e7YGKvsJguwfZMfEDJwQkL1ffooXG2/YBUNLvv1ojr48d6ldUHQqTA G0jIUWjyEm4udb8C+C8qtfaHWlBgIi475KOj2YiqQMg7iYX886KehH4jM+KJgNbCIhDh qo+lhTzt/pLqsCNewux/gxK8B/oPpx96SrLBQukU3uH13WftdBoohuvOgACI9JZ985bS VQp2XiURg5IftCsygZj3Y6yZpwZPGrrrR5kCg/WOZfpwHaxJnT/JwtQZ6TilxE6h/7/n dbeQ== X-Gm-Message-State: AOAM533ZkKwODSnhj41nzCHPf20rlCMApiykLZPah1PMPzFH2G4IX+hv VvshdQ00eSwYcSZw0w+IGpDgKTK7x31ZkX30+ULsKMpdD8q256z/D2dD6nl5o87/T40mueYICY2 s28ATmuhGtrFGMg== X-Received: by 2002:a5d:498c:: with SMTP id r12mr12851504wrq.31.1620398650416; Fri, 07 May 2021 07:44:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTUSY9yat3Yq68EUlkMCcRoADc9UMIi0CNyQErfTSuxO4A4BB59fJXUwarlSImz3l6WDzCOA== X-Received: by 2002:a5d:498c:: with SMTP id r12mr12851489wrq.31.1620398650237; Fri, 07 May 2021 07:44:10 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Laurent Vivier , Paolo Bonzini , qemu-ppc@nongnu.org, Peter Maydell , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Gerd Hoffmann , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Berger , Stefan Berger Subject: [PATCH v3 11/17] backends/tpm: Replace g_alloca() by g_malloc() Date: Fri, 7 May 2021 16:43:09 +0200 Message-Id: <20210507144315.1994337-12-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210507144315.1994337-1-philmd@redhat.com> References: <20210507144315.1994337-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The ALLOCA(3) man-page mentions its "use is discouraged". Replace a g_alloca() call by a autofree g_malloc() one, moving the allocation before the MUTEX guarded block. Reviewed-by: Stefan Berger Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- backends/tpm/tpm_emulator.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backends/tpm/tpm_emulator.c b/backends/tpm/tpm_emulator.c index a012adc1934..9553cdd891f 100644 --- a/backends/tpm/tpm_emulator.c +++ b/backends/tpm/tpm_emulator.c @@ -123,12 +123,11 @@ static int tpm_emulator_ctrlcmd(TPMEmulator *tpm, uns= igned long cmd, void *msg, CharBackend *dev =3D &tpm->ctrl_chr; uint32_t cmd_no =3D cpu_to_be32(cmd); ssize_t n =3D sizeof(uint32_t) + msg_len_in; - uint8_t *buf =3D NULL; + g_autofree uint8_t *buf =3D g_malloc(n); int ret =3D -1; =20 qemu_mutex_lock(&tpm->mutex); =20 - buf =3D g_alloca(n); memcpy(buf, &cmd_no, sizeof(cmd_no)); memcpy(buf + sizeof(cmd_no), msg, msg_len_in); =20 --=20 2.26.3