From nobody Mon Feb 9 21:38:17 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=1620398625; cv=none; d=zohomail.com; s=zohoarc; b=Ji0pnIy9jOFCaBvUv0orJ2t6bK7Ncf7RNxbarPguy5n6pO7D+xfO5Jf4b1WrOLc6g8BKpduYH17wzuFq48imLnmYeLg5QItQBRsUUkcoxNQfrX0gDBtXjOeRZJUMBg/tEO8U34YlS6sph8LAw1Epq4xx3mQS8FvKfMzsKtflEWo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620398625; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=0Q+1JmkmHePwynNhULjY5tlZHv+f3d17hAW4SIJc660=; b=ipDzN1oPWjkrFitJR70CROAVnK+Eq6YME5g9O/4wbdfFQLuZCnqIbaiIMWbC3/OUh16gbQ8COSrgyo5b+i4ZmPGsQXNkBU6Bc8WVRfwqlAvedirC34I7d+StGLpdr85Re3b1uqX6MonZav4yqhZBkLRzxiOLnEMY+REYLZzomAc= 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 1620398625623598.2279247277936; Fri, 7 May 2021 07:43:45 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-431-YQ1MgfrAMYqYgXBIYZ8aJw-1; Fri, 07 May 2021 10:43:42 -0400 Received: by mail-wr1-f72.google.com with SMTP id j33-20020adf91240000b029010e4009d2ffso1234940wrj.0 for ; Fri, 07 May 2021 07:43:42 -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 i2sm10411140wro.0.2021.05.07.07.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 May 2021 07:43:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620398624; 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=0Q+1JmkmHePwynNhULjY5tlZHv+f3d17hAW4SIJc660=; b=T4RiVvDIsugnH8QYf7EtaNA6TDsGSgyjnEhDhhIe6sXlCOL/k+zkJwt+Rxhq20rM8PR3ko gJyP35CVkwehN5RfafacaQhNg6tR8RPMlXMN+Q4rQIS6C+FAI084drmPNP64PgSnqMJOF4 EGUA2uQh+U7oPfTuKYux0OTT+uWZGUM= X-MC-Unique: YQ1MgfrAMYqYgXBIYZ8aJw-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=0Q+1JmkmHePwynNhULjY5tlZHv+f3d17hAW4SIJc660=; b=m8vM8U35yooaY0W62g/PwsO+HsCst6CfUKut9LUM8rEsyIyTWepM7aH/5891N9mU4s Ork/4ZC6lxcdhKKVZl3PKemplNjrSeBs9TSXuJ2xWWASECP58K+9xhiipigOJKqwEUYs dbtyqlb32HTixES9rSxoooKkHIdxRkWHuDpki0EfDG18IcjEFE3NpohwGm36q5i5wtfp a7KLNsSOdx3Zl8Kdn8HovrltwtmEnQ4hXqL4UCsDHzXF8ndut2GgcSwnM00pSC8YYx+U 7UDmmOE3gWED17W1xEeHHfwH2lJd29hqZAmeSQL2R2BAqDFxtI3y3iFd0A2ET46LiRKe rK6A== X-Gm-Message-State: AOAM533cE7WKE/k1fvfg1alk6MN3Fjx7ZofZ42gn7xuOb3oAtGxb8ai+ WG86YAnlH/taL1Nvf9pIZ7NEalFO+edAChyTdqnhLgeGHKV1mJBbwHOWNLfSQdW5Qn0BUpv6IGf NlFhIs3VrH+knIQ== X-Received: by 2002:a5d:64e4:: with SMTP id g4mr12745246wri.366.1620398621515; Fri, 07 May 2021 07:43:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq+8a9eTWd9LLo0lKbFnav+n6uJJCUttMkNpC1ladPYpd+vHRsfQgfmgc2chAdH48leiYagg== X-Received: by 2002:a5d:64e4:: with SMTP id g4mr12745233wri.366.1620398621414; Fri, 07 May 2021 07:43:41 -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?= Subject: [PATCH v3 05/17] linux-user: Replace alloca() by g_try_new() in ppoll() syscall Date: Fri, 7 May 2021 16:43:03 +0200 Message-Id: <20210507144315.1994337-6-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 --- linux-user/syscall.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 2fa6b89b3de..0bf4273fc7a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1605,11 +1605,10 @@ static abi_long do_ppoll(abi_long arg1, abi_long ar= g2, abi_long arg3, { struct target_pollfd *target_pfd; unsigned int nfds =3D arg2; - struct pollfd *pfd; + g_autofree struct pollfd *pfd =3D NULL; unsigned int i; abi_long ret; =20 - pfd =3D NULL; target_pfd =3D NULL; if (nfds) { if (nfds > (INT_MAX / sizeof(struct target_pollfd))) { @@ -1621,7 +1620,10 @@ static abi_long do_ppoll(abi_long arg1, abi_long arg= 2, abi_long arg3, return -TARGET_EFAULT; } =20 - pfd =3D alloca(sizeof(struct pollfd) * nfds); + pfd =3D g_try_new(struct pollfd, nfds); + if (!pfd) { + return -TARGET_ENOMEM; + } for (i =3D 0; i < nfds; i++) { pfd[i].fd =3D tswap32(target_pfd[i].fd); pfd[i].events =3D tswap16(target_pfd[i].events); --=20 2.26.3