From nobody Tue Feb 10 02:50:07 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=1620398606; cv=none; d=zohomail.com; s=zohoarc; b=aZn3LDDOsEdHqREjtzgxxxrwujHGkwMLWm5OniCPn/Dw1hpNulfnVWFQz4OVDZ0dPXVpHeqYG5Ld9g0q7XDYh6zhTDXHgoifiK46lNhqU+Dqq1kDs5IIrmBlXvXlK6fnPpe+cW60XaKnA3Bo8lk0F7+b3sJKWItEwth4yMWwbIc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398606; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=TX2Xz11Yxqn3cVVJ/gzPo0vFUN0FblHfQJn4P/Y+Hk0=; b=OA3zixivYBm8xzHK9ubCyy1QOR6Lb8MD6KaT+GOFoYEo7+pyhTE1wUBCP7iX1kzo8tUiewAZbovrMmt6ZWtj8bmDT60sOoQmmjC1a+vANHBYxaGZZUVAY4UjZMjf3B2SZN9a1ve+KsVLTdybxPXZk6V4k+eEVHVarnCB46rY0pk= 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 1620398606743189.64562255450426; Fri, 7 May 2021 07:43:26 -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-593-z4RXykocP76VUH_MTI7wvQ-1; Fri, 07 May 2021 10:43:23 -0400 Received: by mail-wr1-f70.google.com with SMTP id 4-20020adf80040000b029010cab735fdeso3679504wrk.14 for ; Fri, 07 May 2021 07:43:23 -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 i14sm23099111wmq.1.2021.05.07.07.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398605; 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=TX2Xz11Yxqn3cVVJ/gzPo0vFUN0FblHfQJn4P/Y+Hk0=; b=VRIbKc9xeT5EBBykfg3piVaJ+oJ5DyKaIqsujgchXmbpiDkBeSdW/iBc8b+uFx1sgZbuD8 2x31q6pT3dnlYns6oqWMr/jdVyfZY4QRZ6zofFv+Zl/obaOF2HJJMDVWJlww+l7+TKo2Wx Ia/XmI7fINKbMWld8Up4Df8HOuikmno= X-MC-Unique: z4RXykocP76VUH_MTI7wvQ-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=TX2Xz11Yxqn3cVVJ/gzPo0vFUN0FblHfQJn4P/Y+Hk0=; b=nBD58f7eWSBfLiOQiFw8CNlPSGVRi6+x2nJYqFCsr85p8Ywd06Z+qcM39vyZkr8y6r qqph1v8Az/IHQ1lMppUswry0mx4/h4t1FhEghAKmzdL3x7G0pU/7oGjwP0DeVttFu0gx uFWssMTeO6ClO6ZbSoL5Rh5wjAVe1yXZQ0N4z6ry93/MvjGkpi5db37EH8haIbTANMbP 0FGBuxgPSO+LHGYVjCmtHUTPTy4AHUh8YE0AeDUtdBGUypYxbdQvCkIIKa/U8FRRaf6t JMc3TBRFtXs7v/hEHaijLV3/yam19lJ6lSfYroyeTqolx0KnQxKu27iypAprXPUZlpwg /aVA== X-Gm-Message-State: AOAM531imhdwAuOmOxYDVKMVdPeCVFUyP2UihTOCK0HvQzAcmcpAyVZR Qlu7Tm2v9vAVovGcWzrqqlvyZPCBj4HFgdX1B5yduCO1WBr0SAWLZnRtNGK+OuF3G32jtbPDd5Q 3mL4/M1F+NYFj2A== X-Received: by 2002:a5d:4810:: with SMTP id l16mr12459995wrq.44.1620398602685; Fri, 07 May 2021 07:43:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbBHiRPbLZTqg/6vC8WRerq8TTv4Coun5JgZZb3kUj3oCXgJlkY4EzdyWqLFhr8EGOc5a3pw== X-Received: by 2002:a5d:4810:: with SMTP id l16mr12459975wrq.44.1620398602565; Fri, 07 May 2021 07:43:22 -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?= , Warner Losh , Kyle Evans Subject: [PATCH v3 01/17] bsd-user/syscall: Replace alloca() by g_try_new() Date: Fri, 7 May 2021 16:42:59 +0200 Message-Id: <20210507144315.1994337-2-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". Use autofree heap allocation instead (returning ENOMEM on failure). Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- bsd-user/syscall.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bsd-user/syscall.c b/bsd-user/syscall.c index 4abff796c76..6db05988f1b 100644 --- a/bsd-user/syscall.c +++ b/bsd-user/syscall.c @@ -355,9 +355,12 @@ abi_long do_freebsd_syscall(void *cpu_env, int num, ab= i_long arg1, case TARGET_FREEBSD_NR_writev: { int count =3D arg3; - struct iovec *vec; + g_autofree struct iovec *vec =3D g_try_new(struct iovec, count= ); =20 - vec =3D alloca(count * sizeof(struct iovec)); + if (!vec) { + ret =3D -TARGET_ENOMEM; + goto fail; + } if (lock_iovec(VERIFY_READ, vec, arg2, count, 1) < 0) goto efault; ret =3D get_errno(writev(arg1, vec, count)); --=20 2.26.3