From patchwork Fri Aug 19 15:39:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 598499 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:4388:0:0:0:0 with SMTP id w8csp1498456mae; Fri, 19 Aug 2022 08:41:48 -0700 (PDT) X-Google-Smtp-Source: AA6agR5cmKeLlsVna5iOQ9FBnWoxZIoSRhQUpjdJI3rn3nh3dssu7Z8SYVHaLEkfxi/3yhfxf/J5 X-Received: by 2002:a05:620a:12e6:b0:6bb:a583:76a4 with SMTP id f6-20020a05620a12e600b006bba58376a4mr5530635qkl.424.1660923708544; Fri, 19 Aug 2022 08:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660923708; cv=none; d=google.com; s=arc-20160816; b=XWFb/upzbSssdHNutXtCSLChacaxIpvVnVrIkTdkNBwfJERsjmhKReU9VqBJoiPub4 GGQYcoSlsWPltnwBC3uiqiKkRKqQ64MVVxgk3tBjWr48A8+3VnSBtoUkmHdqc8VE5ZCz oOFZaeKaxvEtTYszf4Y4pkEA317Mra5ljhe2mr/BvEtB/3dzsfJWOeJtVAw2X2ykdVcI J4ybWU2m0wM45IZutp/jmf8l6hr7Hxn7ev0yJUuUxYBj8JrsJmZhMqW4NFc9y5ZNmovO avkzQ+as74DJf/mZvPRaaqDpEx8vPMYlkSXrRj8hZu+mXLTwu3LYTszpcmE83t6EIECF mjEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=wQwzIcXEd8CDalnfbzxRsvGcMSl1lPN2VEyNH0COQ4g=; b=V2Q9lsIXUP69/LcpCbeIL3TO8ddsROeHQKa5wNQfTp97bYLK2985hnrKIOQEJC6AqB NzrPaeZdwy51xfNHjXyttKdBIrr7wMGTAL1FRrzc2IEt4rYEPrQerdw0keI6pGQ86G7w q9LOoDHqZMityZAc1gSPRGSw6gt7fp3T/w2M4Kz+dZoMXAX4e28UeSvqT5Y5d3oOx0Up UsXSF16Glmi4KhQHynii33Ml+Tde143hMOhfM1PAV4RUoaB/M0mdCtAPtMW6pZnPq7xn vmUJ0LhMPV+YtBfYnqRX8HGZkI//ojIaCVkJq5S7kidxLT1exOsOf1EK2qKVmi3XQFhs vRsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q6HzCqbT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u7-20020a37ab07000000b006bb2661f405si1923634qke.301.2022.08.19.08.41.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Aug 2022 08:41:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=q6HzCqbT; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:60644 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oP484-0006Mx-3k for patch@linaro.org; Fri, 19 Aug 2022 11:41:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53652) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oP466-0005bE-HI for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:46 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:37840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oP461-000648-6n for qemu-devel@nongnu.org; Fri, 19 Aug 2022 11:39:46 -0400 Received: by mail-wr1-x42c.google.com with SMTP id n7so5625006wrv.4 for ; Fri, 19 Aug 2022 08:39:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=wQwzIcXEd8CDalnfbzxRsvGcMSl1lPN2VEyNH0COQ4g=; b=q6HzCqbT4CxQJgU/Nb6o3oeyUw2LATV+pyhvZw383EKY1FJay+0TS8805bWHjrpxu/ BJU3gwW8rqNEiKb3G+qEkUgSNzwcX+TJ509b4Mp8LIxkwoEopizFVtsaHyje7O4mY9xL tSwCvWbM8KBJFRZ6caejCRras6d5ASizmHcmXcZFRdUprQq9h0RQz5sW5GJUEHDcwITc d7stwSNC+UFtFmAi6hlmMqygehSEhLC/J8cdeT8mgwCLt7IZ9loGRWcOnjrkG6c19MXz K7BQgYcU+JPh/5ydndEfNHZtXZE/AJ6mbXxmm0XgB2PMkHTD2gZCg/m8HgspaeS9KSxB /7Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=wQwzIcXEd8CDalnfbzxRsvGcMSl1lPN2VEyNH0COQ4g=; b=HevEyGDqVjkFtM+slIWKfG8O5Kh28DZGRxGyHgs5CVXwwWZowP58x2zn9dagbQIcfX cIk3RsXy3abXrFlGgBwh77TL/+ithN84jkVtOOIDOEsEeeRDJaiaabi0H+7KOx9cmEz1 Afa7Hjz1Wmwn1Cg5oh2x23yUHjrMPcGu3ZqCrDFGRLcC9FfuPLe8u23sHxQjiizX/CXx sCfKwrL4j/UqzSFlmUgePUnRaecqqrzvgsjW/569F7RCmXQ61XG/XK0BsrkpsymsS69d V43ZjD7xtKQwRQvgkfrqQNZvUiHQ2VY7nOFqksuhDn0wo1ljvYOyy1ANx9STmh4hRk1F okWw== X-Gm-Message-State: ACgBeo2oc7kD2tOVH3KJ/wUx1rmmuDMiuBL8OBKE9OhGp/aXaQfNvaVb s2/qoozpeYWAlirhkAuiNWBmP9lcWdLPEA== X-Received: by 2002:a5d:668c:0:b0:225:333e:15f3 with SMTP id l12-20020a5d668c000000b00225333e15f3mr3442249wru.494.1660923578689; Fri, 19 Aug 2022 08:39:38 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id bi13-20020a05600c3d8d00b003a54109a6a0sm5558396wmb.3.2022.08.19.08.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Aug 2022 08:39:38 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Samuel Thibault , =?utf-8?q?Marc-Andr=C3=A9_L?= =?utf-8?q?ureau?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Daniel Henrique Barboza , David Gibson , Greg Kurz , Dmitry Fleytman , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , qemu-ppc@nongnu.org Subject: [PATCH v2 03/11] chardev/baum: Avoid dynamic stack allocation Date: Fri, 19 Aug 2022 16:39:23 +0100 Message-Id: <20220819153931.3147384-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220819153931.3147384-1-peter.maydell@linaro.org> References: <20220819153931.3147384-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Marc-André Lureau Reviewed-by: Samuel Thibault Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- chardev/baum.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chardev/baum.c b/chardev/baum.c index 6a210ffd815..0a0d12661a4 100644 --- a/chardev/baum.c +++ b/chardev/baum.c @@ -299,7 +299,8 @@ static void baum_chr_accept_input(struct Chardev *chr) static void baum_write_packet(BaumChardev *baum, const uint8_t *buf, int len) { Chardev *chr = CHARDEV(baum); - uint8_t io_buf[1 + 2 * len], *cur = io_buf; + g_autofree uint8_t *io_buf = g_malloc(1 + 2 * len); + uint8_t *cur = io_buf; int room; *cur++ = ESC; while (len--)