From patchwork Mon Mar 25 12:35:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 782315 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp1146452wrt; Mon, 25 Mar 2024 05:36:34 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXTqoIux5PbCCxc4tCddUPU1KVdUeDmKw/c9rijrzmJzUFrd4YwGPQg7YM/vrtC+38/uA+01q7OnoITnp0VZUY4 X-Google-Smtp-Source: AGHT+IGi63FEpZhfgl5JtCTdloH/l+bysTV65rkvmaOLanHQIJBDH0QLsZxnT+qFInHqSHTgifDt X-Received: by 2002:a05:6214:2b0c:b0:696:4855:cf18 with SMTP id jx12-20020a0562142b0c00b006964855cf18mr7014495qvb.43.1711370194723; Mon, 25 Mar 2024 05:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711370194; cv=none; d=google.com; s=arc-20160816; b=r4yQ+z2RMqtspa3eFDx9TWEZ18Aiz4gb/8J7C8uCz1S7bpzlJa4pKqSV9v5OwRuBT5 CQ9P1eT8xJ/qqfQXNp0SRYyX9ar90gFNamv/06PZyf6fOX7uPnWFj71456N2Y2Uy9zHT PNokzv+fq/O3n2PkEQ8WzS0d1er0vUtCfpCOjV9J5mNEm9s22OzrAka+iTWNN5onHPyt kFpuBuzqxbg4wLb6h73a65HfshUQSD810he5OWkB53yCXcGkYUN6QPEbNSa0onhTdRR3 BALZnaTgGK18X5+9qEU1RdAvIuN2IbfEE8aPoOgeYvIXRGVmYNxZd4VNtdbY5ckC+mwT gsGw== 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:to:from :dkim-signature; bh=eRU+7TF6IV9xXJWV5nC1V9vP/PTuItRJkSSU0GlEqY4=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=H2D2WqUvDUE9qMiyx7pq6kCwtZSsUOQfu4GoYU2mS4wniE+Ad9dszjKr5ITAmeDRnC T8RCso7DOPvUQBEajL03S2fHWOJz67G6j/GwtPbLQticSW+Nl38QWyq1J58AelNN6vHq zDSbQ0rRBl7K6zZQT3hFPe52pTA1Lq74BayxWXOCaY/ePMxtDJLcLcog0JbexzR2Xsp8 cVaNJYgS7FvUbmQweJe57CdS+cs/QaC06KJhDlRMBBSyy0ib/Ae6w0JeD/NkF1p/Rkzf tb4R7UoElG0ARQjfR+UZMsLJV7C4sbh5c3Ga4U6dk9L1xxSd/zwv+uGV83CWKEIj0mfj e69w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KA3xNX8B; 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 kk11-20020a056214508b00b0069683ff98bfsi3647325qvb.26.2024.03.25.05.36.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 05:36:34 -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=KA3xNX8B; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rojYT-0002Hr-TE; Mon, 25 Mar 2024 08:35:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rojYR-0002Gj-FE for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:55 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rojYP-0005d9-Tb for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:55 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-414881d8956so6228445e9.3 for ; Mon, 25 Mar 2024 05:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711370152; x=1711974952; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=eRU+7TF6IV9xXJWV5nC1V9vP/PTuItRJkSSU0GlEqY4=; b=KA3xNX8BX+47r6wLM9A/TRQGbSVGqsJxc7a3hE8P9MAnp+yqc20Q4RbsjUkm0Svv8u V1va3bo3TG8edlH2M3bUoflGAg8YdajqtZdHLILFxbg/bVSuVPiA4DJRjjniheRupDqO W7FkosTIX19Cvs9cHlGwUVccvyO1chC45L/zMHbEDidDVVn0jZoLCD2Fl9o6NJArmnw8 Dz59jdD7GAX6N2H3vL63ep4l07yaR9dQyOEmsBR4EJRy+UpOTL4M9Gf0b7vSPU0cFcko aazzWUr3P6WbgWVx1Dlh6W6mynQkgsBybgTu3xQ7CGWka50qFk58Gh/8zUpIQkOYZL7L RKTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711370152; x=1711974952; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eRU+7TF6IV9xXJWV5nC1V9vP/PTuItRJkSSU0GlEqY4=; b=D4NPjt9tbn2CmjzBxdtL51fQCtilgnmuyiNOMd2d1LejZbLATrurQ60W9+I98IG91T 4zvVxxithzJq5FgmmZ41CwP0+DkIJyywWEeCniA8/PQUF1eHFnUN2LwQumrQXPJmeJ3C 8Qnaynojr88n1GL7hMDzBVw/nP7JuT+wpHi9xqiqsEdFKuPOz9sAUwFsaKn70SQJhcFZ 7pOoaPLzqIF9wD711KdKwYy5SIpe15dUxc8D82ZFDJXX+Fx2WbtNZUVYM6MoLpFQAR2g jVUvNbESPN5Y1uK4evi2+YukRqMlfq+lJ8gqARo3kaThV0K8CEF0WKjR439mkhf97bmD 7pXg== X-Gm-Message-State: AOJu0YzYs207OqBD9eigOluz4ZZyiEV7ibdej+dTq+IWQe/ox1Q5wVyo k6DLh/IMR2NPHMqK3h7qRlsOPgIPnMlGGOA+WZpaI1uKCyjWSEyTRPEEmw23+dXOZyk+Z5lWdSZ y X-Received: by 2002:a05:600c:55c6:b0:413:fea7:bd19 with SMTP id jq6-20020a05600c55c600b00413fea7bd19mr4688293wmb.15.1711370152524; Mon, 25 Mar 2024 05:35:52 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c339300b00414041032casm2303877wmp.1.2024.03.25.05.35.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:35:52 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 1/7] tests/qtest/npcm7xx_emc_test: Don't leak cmd_line Date: Mon, 25 Mar 2024 12:35:44 +0000 Message-Id: <20240325123550.1991693-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240325123550.1991693-1-peter.maydell@linaro.org> References: <20240325123550.1991693-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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 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-bounces+patch=linaro.org@nongnu.org In test_rx() and test_tx() we allocate a GString *cmd_line but never free it. This is pretty harmless in a test case, but Coverity spotted it. Resolves: Coverity CID 1507122 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Message-id: 20240312183810.557768-2-peter.maydell@linaro.org --- tests/qtest/npcm7xx_emc-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qtest/npcm7xx_emc-test.c b/tests/qtest/npcm7xx_emc-test.c index 63f6cadb5cc..2e1a1a6d702 100644 --- a/tests/qtest/npcm7xx_emc-test.c +++ b/tests/qtest/npcm7xx_emc-test.c @@ -789,7 +789,7 @@ static void emc_test_ptle(QTestState *qts, const EMCModule *mod, int fd) static void test_tx(gconstpointer test_data) { const TestData *td = test_data; - GString *cmd_line = g_string_new("-machine quanta-gsj"); + g_autoptr(GString) cmd_line = g_string_new("-machine quanta-gsj"); int *test_sockets = packet_test_init(emc_module_index(td->module), cmd_line); QTestState *qts = qtest_init(cmd_line->str); @@ -814,7 +814,7 @@ static void test_tx(gconstpointer test_data) static void test_rx(gconstpointer test_data) { const TestData *td = test_data; - GString *cmd_line = g_string_new("-machine quanta-gsj"); + g_autoptr(GString) cmd_line = g_string_new("-machine quanta-gsj"); int *test_sockets = packet_test_init(emc_module_index(td->module), cmd_line); QTestState *qts = qtest_init(cmd_line->str); From patchwork Mon Mar 25 12:35:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 782316 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp1146455wrt; Mon, 25 Mar 2024 05:36:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXLl9C0SR/JvjvWYnqR6FvhsAIGkY+5sPjNaXdUlv7OKKXiWw9sjYysd9rhYsPW5iCoaNTueMUJV6ra74jNCQpI X-Google-Smtp-Source: AGHT+IEqAI6KFSs9jju1SzK54F/uKo/pkapsPegJq76Qpb422XeUeeZ1pbsNr+nNa1O1axblr1l1 X-Received: by 2002:a05:6808:1296:b0:3c0:395e:fc3 with SMTP id a22-20020a056808129600b003c0395e0fc3mr9832812oiw.28.1711370194856; Mon, 25 Mar 2024 05:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711370194; cv=none; d=google.com; s=arc-20160816; b=z6lBl4K84hwNzbyo2nBdajlP+Fa8JYm48FMaOeDpMqsnnj8/qDRP3dvQdFRg+ulWdL OnJa2GBUoYnfRHof+Rlrw7TX0015kGwINEydYaLOBKCAd0YHsQ7eMEgd2McQzgTmAxcx 9Q0VR4RtQ6/dYDy6HkgiNZTEzhBh5/d9XoMS5BzunmozS4l/rY6sGhEVXMX/agikHsM0 0y2fr2P61QJwwFxM+wCCOZUZvrfEe2Ti7lUAu6WPTvdPX8MlQ54nKbOOPcLxHGaHQZ35 eWrtSwKdOEZagWqjuy7K627TVduKTpdmGDSoWxSgQ8USEhLspSukoEEOA/AurMegSiFS 0TqA== 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:to:from :dkim-signature; bh=Hzj0HVgtYH8dljqUEAkMRgJehd1werpG8tMX7PZdRLc=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=sXw8tsgsEaKN+y+lkx+doRpsNjZW6G2D88xY+ZcnxUWAJyFUCmCuRzUzrg8FrRjCvh s/juBqCK8bvj/o0jPcgvyxYCeexQ4+ZAXUGUuR71WoZFR5weo3Z+eRCV0xbDP+ATVzvc kvPepOLc3u0788MZE1id0DkL54etTMtDK8mB7g/h3h36pfr/vV2TCptFeBh615FDoh7F abpDqHcGxSYlJ6gp+8K3EL+bUCFf96jBHJT8dBD9THz5Hos7aaXeAnMVdrV5e4lsx8e6 C1NBeY7SQxLqyoNyIolCcAOY0orP6/WrG7W4sT25aOcjChhXK/jHSQBtyHY44bTWAZ6T ABoQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ac2MfBHY; 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 gb13-20020a05622a598d00b00430ef644d5csi5337830qtb.275.2024.03.25.05.36.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 05:36:34 -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=ac2MfBHY; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rojYU-0002IN-UX; Mon, 25 Mar 2024 08:35:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rojYS-0002HE-Nt for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:56 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rojYQ-0005dF-BU for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:56 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4148c65ea45so148045e9.2 for ; Mon, 25 Mar 2024 05:35:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711370153; x=1711974953; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Hzj0HVgtYH8dljqUEAkMRgJehd1werpG8tMX7PZdRLc=; b=ac2MfBHYIZalnEmXb7K4Gy1LENJmRojpjcykyPygvY+CeXGAx0OZlf4b6tJ/4CV3MA balzCfRm9DoPguLF64SkzjA2msqIwN8fNPUIi9KxfY4COXThlMSuf1kGyofrHTMWDIyh T7VUptJYtz9nPiMZLVmOOVS8jylCz9ugeZwufH1oW7OFmZ1IWC+XMvFE86T3m7pUqWOr 4i9FF2iFpn7tQc4TBGVv5iePd8S2645DWTFomDcY8THuPB8zFKvtFpW2CBWp5XDH5886 Y2G7iDT09W3dhcbX2A3B7Dduv24j+q7ye8p9hkiWBdwqraAyY18R9IWdCE/B17wipE5z D8mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711370153; x=1711974953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Hzj0HVgtYH8dljqUEAkMRgJehd1werpG8tMX7PZdRLc=; b=SHSwkh9zYlNJvXaBZIvdO0x4vJBPFrlOF8Wmg25DjIDJSF562l3FHKLr/ZYxdrzJZw Fv7sHn/zYuH39YCvUupuGov0xODbQshMpWK06GtXjtPUM5aR33fkzhOw+Cs0OMPfnEo4 Uf8eh4f4BBzrye7vsSKL94TwN7FM61MEfhiK6IwIQ+5IDdDkaw5TH3jXsa3ESvMIxbqM ynmEzo+v0yhu3x0UT1XgSCVvgJEjapa0TSiNnDFdAZGGST9v9Ju91SAutruP6q3NZn3v lq9RSqrMqafOxt+SJh343xQP85P2YKVDidkos2fB7O6o+3dGu7T+Gtwif8AqHKHaaJQd rzJA== X-Gm-Message-State: AOJu0Yx9mRKkxnRnGaRxtUA2foXC3LxQT3s/Hcst7Isu/lABd8H7qlxr hbxnkIGJj2w1/cNTZuGfQ/Vve5kpTkT9UyRnD2RFFEigYus5pOy2RkvIQ8DNrMftX41h3CZUWH4 Y X-Received: by 2002:a05:600c:560c:b0:413:2c11:f795 with SMTP id jr12-20020a05600c560c00b004132c11f795mr5735095wmb.39.1711370152910; Mon, 25 Mar 2024 05:35:52 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c339300b00414041032casm2303877wmp.1.2024.03.25.05.35.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:35:52 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 2/7] tests/unit/socket-helpers: Don't close(-1) Date: Mon, 25 Mar 2024 12:35:45 +0000 Message-Id: <20240325123550.1991693-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240325123550.1991693-1-peter.maydell@linaro.org> References: <20240325123550.1991693-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.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 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-bounces+patch=linaro.org@nongnu.org In socket_check_afunix_support() we call socket(PF_UNIX, SOCK_STREAM, 0) to see if it works, but we call close() on the result whether it worked or not. Only close the fd if the socket() call succeeded. Spotted by Coverity. Resolves: Coverity CID 1497481 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Message-id: 20240312183810.557768-3-peter.maydell@linaro.org --- tests/unit/socket-helpers.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/unit/socket-helpers.c b/tests/unit/socket-helpers.c index 6de27baee2e..f3439cc4e52 100644 --- a/tests/unit/socket-helpers.c +++ b/tests/unit/socket-helpers.c @@ -160,7 +160,6 @@ void socket_check_afunix_support(bool *has_afunix) int fd; fd = socket(PF_UNIX, SOCK_STREAM, 0); - close(fd); #ifdef _WIN32 *has_afunix = (fd != (int)INVALID_SOCKET); @@ -168,5 +167,8 @@ void socket_check_afunix_support(bool *has_afunix) *has_afunix = (fd >= 0); #endif + if (*has_afunix) { + close(fd); + } return; } From patchwork Mon Mar 25 12:35:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 782319 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp1147065wrt; Mon, 25 Mar 2024 05:37:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUwfE4ieXwHHTx7EvS9nK9m9w8eoTWlguf43a8Kv3LbCafObdl78/l+KeX4PJalbUD470ok99xQwlFiHIDmtF1Z X-Google-Smtp-Source: AGHT+IE5VNXVtDNLMvZ3R5X3YyclnoVJ3XjgR42xq///EldK1y5a2OtPanV4Jt/jPkBhTt2lvUa1 X-Received: by 2002:a81:bb43:0:b0:611:2133:8658 with SMTP id a3-20020a81bb43000000b0061121338658mr5255781ywl.52.1711370274814; Mon, 25 Mar 2024 05:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711370274; cv=none; d=google.com; s=arc-20160816; b=bxElRGpX0+0e3luXB7rJJH27k0HOOJb4eHYiRVC6bQdBN9UuHS6NRfMyd0QEcwRYkv buyO5mPD4lBrG/H8vmOf0IP3Dq6gzsoZKFZMwLaOeZMjqNWDwmB8PKgfDdVu3QVczSel s+KWpUFgG1u+oqcAhGq/mhoKEwjltFfAL34o/gtKAj9QnayAcEPzbiKzpVr3V6Qs77dl /v3StDoDKxOjek18dmxw1CeBWio469VoMfB6GOImwyuogqr7ocTJCTmdZuxiBR3u5uv6 0F/C1jUJSaiPGBueCVyDlPOrCoFDzNg8Xx8RI6qTMoHdyOTfqNJ1z7r4U+T7ufzq/Hm9 Bj+Q== 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:to:from :dkim-signature; bh=aGhWsSP/npTCiFe/sHrNCbxR5PPjNjefjYSTRbPwF88=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=MQPhcZfF33pYzp6jWtSYRY6ru7lnuQdEToGf6W2gmYtmZNQy+wM5Xw+6RJQ0+ITwC0 4MYEG90INUqvd+QKsaqfzxkGVx0tp1rFC22pK8GVqNt4LaykOwRV4o4IgRx314YVDYln Bp5wSkwqiat0m8waxE13TKMiDvruVawyfrYJXYRj2W7LhpR88/ZlYua0BR104qsc0GZR MU3mm52dI6PogCgPMMIFxf8TZElmzsRz+4u8wgUJPw732WqjhoScZmTo21cKwb5r8uNx 5P79uIV18dXq0ketwZSNxT9xMCbkKSOwI6Dz45r+GR++RJaWsg5T9fCHMxuu54Fk0g3v EASA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ygo1IaNH; 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 w1-20020ac87e81000000b004315241d90esi2633382qtj.547.2024.03.25.05.37.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 05:37:54 -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=Ygo1IaNH; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rojYX-0002Ja-QB; Mon, 25 Mar 2024 08:36:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rojYS-0002HG-QS for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:56 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rojYQ-0005dO-Nw for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:56 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4148bd2ce39so2075215e9.1 for ; Mon, 25 Mar 2024 05:35:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711370153; x=1711974953; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=aGhWsSP/npTCiFe/sHrNCbxR5PPjNjefjYSTRbPwF88=; b=Ygo1IaNH6FB5YXtSobiQEt8PzoNuvjYhNUE0vp/X+iAzTm/FcGTJ9FwmOQ+RVDImM9 FpSERsaIE9OthTglJM9qukogC9Er2aUb1m1o4JpIGeToNxuoYH21/DcJRloZLuIIXMxA F7agCAnX3c7HmYxWd6MJo5qh4F8p/TCW06OJrqx7Dsq+FrZiNoaD++bDbsHMGb6e89n7 B/2f+mPag3y13pJsERp0aokbPb8VFLM6ePKz41nEZ3R2jOX7YitSn+FAHl2slgbaJH4z fJlLNcWBAYVf4/FZUDsTdd7wqLSV7EZh6WTZ2JOPxPpzLJ41eu0O4VjZV4klQIvakbud pSQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711370153; x=1711974953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aGhWsSP/npTCiFe/sHrNCbxR5PPjNjefjYSTRbPwF88=; b=ok5wVQ5CXiFti2jaeOodjrjpE6CZ9Bl90/jsCIkRwfvnCgIiokYvpbhR1R5vw+AAFs u6osu6VOGL5OoFKe9Y+By4ipVoPVZzJ/fq/VTizGi/zSaEwRiM4PSvZmSpBdJApAcFam xcLj6Vz15Sy8X2uuEgys3rFCuW38LfAsBmfoHLpMrVqnegQnbZKQDFEsVMHYeA6cpcu6 CCurC9145QyR6G2uZamJdcBGkVsa7xv7AcrxSBxoS7jsI1RCDW9qagodRyKDzVyA4KRb jqDc84HaVDTRWAo8vnvjuU739z7gGyBIWviMwZARBikh0DdCfKW8cndMxZXLJdkBa5MQ 6Juw== X-Gm-Message-State: AOJu0YyyvsOl0XTXtRCjQRNKeDi8lY84LX8Pe07RVoDB7ZSzWzD1B3Fb OV1qn98XOItpBtlrIWoevTLD1YmAIelQG9l/l1hMkOJtVD/lANm8tF+ahT78nmwCaT6x430awm7 w X-Received: by 2002:a05:600c:4ece:b0:414:6c72:8df with SMTP id g14-20020a05600c4ece00b004146c7208dfmr4809223wmq.38.1711370153346; Mon, 25 Mar 2024 05:35:53 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c339300b00414041032casm2303877wmp.1.2024.03.25.05.35.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:35:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 3/7] net/af-xdp.c: Don't leak sock_fds array in net_init_af_xdp() Date: Mon, 25 Mar 2024 12:35:46 +0000 Message-Id: <20240325123550.1991693-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240325123550.1991693-1-peter.maydell@linaro.org> References: <20240325123550.1991693-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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 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-bounces+patch=linaro.org@nongnu.org In net_init_af_xdp() we parse the arguments and allocate a buffer of ints into sock_fds. However, although we free this in the error exit path, we don't ever free it in the successful return path. Coverity spots this leak. Switch to g_autofree so we don't need to manually free the array. Resolves: Coverity CID 1534906 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Message-id: 20240312183810.557768-4-peter.maydell@linaro.org --- net/af-xdp.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/af-xdp.c b/net/af-xdp.c index 38e600703a3..01c5fb914ec 100644 --- a/net/af-xdp.c +++ b/net/af-xdp.c @@ -446,7 +446,7 @@ int net_init_af_xdp(const Netdev *netdev, NetClientState *nc, *nc0 = NULL; unsigned int ifindex; uint32_t prog_id = 0; - int *sock_fds = NULL; + g_autofree int *sock_fds = NULL; int64_t i, queues; Error *err = NULL; AFXDPState *s; @@ -516,7 +516,6 @@ int net_init_af_xdp(const Netdev *netdev, return 0; err: - g_free(sock_fds); if (nc0) { qemu_del_net_client(nc0); } From patchwork Mon Mar 25 12:35:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 782317 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp1146559wrt; Mon, 25 Mar 2024 05:36:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVp1aek1fvhHx6cnrVw0jbwbh1ZyI5rPWHNuhETOhEAwfLjU+pk+kpgse3I2h7eLleWiqYuOv3vODg/zPJN1tti X-Google-Smtp-Source: AGHT+IHxMZjxvUjUy9hOWMgdQJH+6mGJrYsW6zvJLLdYFlNeGd0Dp42RDAY1OmhnYbeUn5rFZn1j X-Received: by 2002:a05:622a:1341:b0:430:d6ae:5990 with SMTP id w1-20020a05622a134100b00430d6ae5990mr10093850qtk.32.1711370209344; Mon, 25 Mar 2024 05:36:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711370209; cv=none; d=google.com; s=arc-20160816; b=MIP5bd6RqDVW+1WFY7IhPWGaCfgRv1q8/1th+1LpD4BM1vBUeB3Jp3KjFrBknh+mOQ R5FtZl1vjnyFBfxGs46ju7mNXkOoW+sQvnd4LtHe6R7nHw5oY73Pt21JZC2qZD+sVyyP QYVwY5UMiipzhQxziuix7CgcZsF8kyIhuOz3dE+7K1T31qkYW54i5ZphN30d92s5D/hN RIjkHtnEA8po718Qe+VBGc+LvUv+TN24YCQblrwsyMjvIEmweo/7tXCODJaubmJebFVE 5Vj1ckNcqXjqKkApNb3Rg14JyqjRduTSuqPjARGx8idQK24Sfk6nbzpjOqGqHZuK+lhU VwdQ== 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:to:from :dkim-signature; bh=GCgvA2TmnxeKrt9Gh3RGTnMyC9ymehvv7sEyBNeOPwc=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=cJle4gUDrfJ7jMUrvWcBdvP0rOESn9XiTFkn0CF27zd0mZ8lzO0rMahnnPJIlFDScM dABv/DHHi6FxZMa9TUth5CAyuYQdpro4zYch4Y0P7H/V5/E16bB5kxYxdAJvaiIsBljM 2TXqcLJAXdnEBJqoHX4KmkTK7TTTASfwgffrf1AeRLM4tSelucIGPsVmpV+S6+TF0DU/ dEDu87Ha7pK3MWAVRIjnoh5pBKAwSAvK0eftTHC1zRPXi0zyTw3vIpc9bCyH26DDEEJr sSSRetdHVcZRzv3gHDrqKhqpET/TR6JXC9kfslUIG4L6Q0vinICjyPO5+BJzqKJxOUPf vyCQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ub7n9wCg; 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 q16-20020a05622a04d000b004313ae19b00si5228142qtx.388.2024.03.25.05.36.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 05:36:49 -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=Ub7n9wCg; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rojYV-0002IO-3p; Mon, 25 Mar 2024 08:35:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rojYS-0002HF-QL for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:56 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rojYR-0005dS-3G for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:56 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-414866f92beso7280345e9.3 for ; Mon, 25 Mar 2024 05:35:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711370153; x=1711974953; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=GCgvA2TmnxeKrt9Gh3RGTnMyC9ymehvv7sEyBNeOPwc=; b=Ub7n9wCgEPxRGmiMrvQ2/W+mRBsbiep1zU7SyHmLQd5rNW2bRSFT8oMIdZembEUPpr J22gx1Z8ZoDFebmlambCthYinal5rwel6TwcoAfMIG1gug9pQ8/HHZ6cG1/cYBkIs6aX v3ERejN0jlCI1DYRw8tBWkz0yq9ED7BbeE3eNyE7pIZt7L/1NSuoXXwOok/AwIYxfEk9 daE/kOScckGyIWLx8+WMu+zZRupIs5mMDI2ESfX6UAsW3dAqdqrEGoAT5xYG3t3Ks5Hw rNt0E/A+U2Ug51l1pDkShFomabHStQZ9B4NQurinSJvcx/A9K0JfdMw5PVA1g1PmX08E CVtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711370153; x=1711974953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GCgvA2TmnxeKrt9Gh3RGTnMyC9ymehvv7sEyBNeOPwc=; b=G+DwC84WGYoHjV95nC+b+gwG6POg+eh6s+MtwmfPU3EhcobWah81CH5aMrQr0plghA 6IwjC8zYqrgqBOjd3aeqFQg7753eLGGfoWJsw3Dp1W4jtm1L0coi8ZG6KNf80wxGd6zv sR89GEilw3jd8Dcm7viw1nAURForX+v+EwWzzXP/BVz/OApJI7AuQmLJQFc3WwH5zHnu HO0i0IOXC6akDuOK6thaKZLAHRiRSBBrjCibuwLp1RFVnLgpddrpB6EdeY/RouOorU1+ KQuveu5Wp2b+j37EjUpqQzRHeNBe/bCybqaTxtwesmgLSREWW4rAUAxh1RfVVE54xj4I rsvw== X-Gm-Message-State: AOJu0YzkEqu3QcNyZSkdEUO0TGtiFu3KIke65agehSui0eIlGKeWPeeJ htkVQBHeEdcAbTD64mLMe643d1dQcR1yzpkCVzYNgUoDyMYjxh+UVpdKSDxFv2JfWrOVowbOik8 K X-Received: by 2002:a05:600c:45d5:b0:414:869b:dbd9 with SMTP id s21-20020a05600c45d500b00414869bdbd9mr3072410wmo.9.1711370153770; Mon, 25 Mar 2024 05:35:53 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c339300b00414041032casm2303877wmp.1.2024.03.25.05.35.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:35:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 4/7] hw/misc/pca9554: Correct error check bounds in get/set pin functions Date: Mon, 25 Mar 2024 12:35:47 +0000 Message-Id: <20240325123550.1991693-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240325123550.1991693-1-peter.maydell@linaro.org> References: <20240325123550.1991693-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32b.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 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-bounces+patch=linaro.org@nongnu.org In pca9554_get_pin() and pca9554_set_pin(), we try to detect an incorrect pin value, but we get the condition wrong, using ">" when ">=" was intended. This has no actual effect, because in pca9554_initfn() we use the correct test when creating the properties and so we'll never be called with an out of range value. However, Coverity complains about the mismatch between the check and the later use of the pin value in a shift operation. Use the correct condition. Resolves: Coverity CID 1534917 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Message-id: 20240312183810.557768-5-peter.maydell@linaro.org --- hw/misc/pca9554.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/misc/pca9554.c b/hw/misc/pca9554.c index 778b32e4430..5e31696797d 100644 --- a/hw/misc/pca9554.c +++ b/hw/misc/pca9554.c @@ -160,7 +160,7 @@ static void pca9554_get_pin(Object *obj, Visitor *v, const char *name, error_setg(errp, "%s: error reading %s", __func__, name); return; } - if (pin < 0 || pin > PCA9554_PIN_COUNT) { + if (pin < 0 || pin >= PCA9554_PIN_COUNT) { error_setg(errp, "%s invalid pin %s", __func__, name); return; } @@ -187,7 +187,7 @@ static void pca9554_set_pin(Object *obj, Visitor *v, const char *name, error_setg(errp, "%s: error reading %s", __func__, name); return; } - if (pin < 0 || pin > PCA9554_PIN_COUNT) { + if (pin < 0 || pin >= PCA9554_PIN_COUNT) { error_setg(errp, "%s invalid pin %s", __func__, name); return; } From patchwork Mon Mar 25 12:35:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 782318 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp1146959wrt; Mon, 25 Mar 2024 05:37:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU001fLxnyO7AEkABM4lukOWCO+mw9kA2toMBO1aOqWX9CZ3Tt+54GfcWE3k0tS6m5ByAvK4McPwgx4Wl7QM/ws X-Google-Smtp-Source: AGHT+IHKeJrMb9bXYLR3rhzYbvKyM/pnJThLmdZMN9ZyZQzsYDjOuVcTdN6XKrvydXXVIo+cIEW3 X-Received: by 2002:a05:6808:128f:b0:3c3:865b:5311 with SMTP id a15-20020a056808128f00b003c3865b5311mr10038099oiw.48.1711370254880; Mon, 25 Mar 2024 05:37:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711370254; cv=none; d=google.com; s=arc-20160816; b=ZJXgY/+Axaynjwak44a81RxHTNDfk5aauHzuRtC0qSldisvnjN3i07Y8OW2YOfj4B2 gQulnbx8Gh6WSoQgLNUN0G3FyJam2KTvwITrrikvZ8NU30MsnoK/zbwdVngHxC4xvtZu IXQ/86sfM7pva/IRD/8XQwXdxuA4GBefYA2v6Gq4o6PLfJYqkRrATSvsQ3QqoV0G0V6f iNnwuWLJOYVjqd+PfEUp68rtaGdeE9qUYOJT4w0AJCu3TwwYWTZbB9yzTaS2K94P5/Rj X0D5xeZdNofBxyk0XLYfFNlqOGQZdLpbbHwIoL1kEGr4cym0j4UJxRPUHAdFojRiXf/A U7XQ== 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:to:from :dkim-signature; bh=cPU63vtq7nGV4qBFhe6DUh4SCq/4JARPRKtq5Gn7vKA=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=MRsp9XiUAqh9KaMZcPRHiP70doeOpi5vyYlsZkBrM2Ls9CO9mzNaI52ihttmMHYh0s frVpP/4d02PgGTeYKUPryTVfz14hgXslS6qvKA1ZRte9QMVan1Q85sfdPki+e87k9aHx gzLG0AD2/SX2xb6rOJx+ruBJ2IRSaiRhAtuQdo1vlnhwGToJc1lk/DavKh38JafRFKuf 7HXTTzfXTyreIsaAgLvoDk2b48N+XKt4UTdVfIHhc1DJN0Mypgt0+t16xa+P7GEOo5LP oJdIgWiXmHbk5R7JJ8KnsYHGFY4lFTpEaC0cGQ3ZtfOkb1veulCZJhPI7mkpwrlyAHQB Gz/A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="iW/PqS6V"; 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 s2-20020a05622a018200b00430a20d021csi5235945qtw.601.2024.03.25.05.37.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 05:37:34 -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="iW/PqS6V"; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rojYW-0002Ic-2q; Mon, 25 Mar 2024 08:36:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rojYU-0002Hs-5x for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:58 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rojYR-0005dW-QR for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:57 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4148c607f31so246485e9.0 for ; Mon, 25 Mar 2024 05:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711370154; x=1711974954; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cPU63vtq7nGV4qBFhe6DUh4SCq/4JARPRKtq5Gn7vKA=; b=iW/PqS6VPldOP78K54KmqaPGL9XCS7yBLaUn2k871mKn+j4dfIK8MJdL+X1sqUK1nF WhoLC4eYZUQILN9x2hQr1X0mBumWApK+yrJS5kEQuWu5Agg2oaxObJJvTCn1o9nW2/xU lu+a6sMPnbZibN7PtRKM+mPmGNgYGGbwgTlXjUggjKOrXUXTR+u46f6OC8WO0J02/A9i lgnK6WQ1rZs3Jw80M78sCWYJKdplMmYeoy+BVvLIw6Yywinj/r0lqxq13ngBdn7zh+oX noo+dtzvWMWC1DESe81wY4TOV09CGCrA9VCl1q5W6a9DQg10BTczpUmW4fPD8KDK3rzz IJ6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711370154; x=1711974954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cPU63vtq7nGV4qBFhe6DUh4SCq/4JARPRKtq5Gn7vKA=; b=CkP5Ufgy9sJxE0bnPLC9Hspir0MIkEliRd+9ZQYFJx8C9MPPQKyPMmaPLBcqaJFuzI YoHrTOthpUrDcv16Di0fqTGw1D/OphC6aveu3Lt96ik1H597def7sgKhLAG3KP6XzFfv p9ytKhQWKEdyerCVdNsdIMxYfOdSvUYwZ5cBt5RanTpgeEUICV3BhQRJSdlewBt3OfQz P0BViEyn4frXMf9Jbf1DpoUtCsQRs/aUUGdGCwqIWSUpv5VbmxK+RQAzmxf9YBS7vQ+R 9n8h/1cY+1lNPSUyazQGKhbseeqsrzBVKvcRAOCtOSfmSGeY83q3xBfAIFMhurIG1XKd sAaw== X-Gm-Message-State: AOJu0YzcTeJ9lupjZiNBiVvJfbVaidFe1Vf9r/3SmReCrnelvfIPcchm zgGauWAqsc16mPZ0Y5ORlaW6qJmADgD147iwj/kXehWlpEess4+qzgNviTcfamyb3KElfX5t72W e X-Received: by 2002:a05:600c:450c:b0:414:86a2:a43 with SMTP id t12-20020a05600c450c00b0041486a20a43mr2496920wmo.40.1711370154162; Mon, 25 Mar 2024 05:35:54 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c339300b00414041032casm2303877wmp.1.2024.03.25.05.35.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:35:53 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 5/7] hw/nvram/mac_nvram: Report failure to write data Date: Mon, 25 Mar 2024 12:35:48 +0000 Message-Id: <20240325123550.1991693-6-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240325123550.1991693-1-peter.maydell@linaro.org> References: <20240325123550.1991693-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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 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-bounces+patch=linaro.org@nongnu.org There's no way for the macio_nvram device to report failure to write data, but we can at least report it to the user with error_report() as we do in other devices like xlnx-efuse. Spotted by Coverity. Resolves: Coverity CID 1507628 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-id: 20240312183810.557768-6-peter.maydell@linaro.org --- hw/nvram/mac_nvram.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/nvram/mac_nvram.c b/hw/nvram/mac_nvram.c index 5f9d16fb3e3..59277fbc776 100644 --- a/hw/nvram/mac_nvram.c +++ b/hw/nvram/mac_nvram.c @@ -48,7 +48,10 @@ static void macio_nvram_writeb(void *opaque, hwaddr addr, trace_macio_nvram_write(addr, value); s->data[addr] = value; if (s->blk) { - blk_pwrite(s->blk, addr, 1, &s->data[addr], 0); + if (blk_pwrite(s->blk, addr, 1, &s->data[addr], 0) < 0) { + error_report("%s: write of NVRAM data to backing store failed", + blk_name(s->blk)); + } } } From patchwork Mon Mar 25 12:35:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 782320 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp1147064wrt; Mon, 25 Mar 2024 05:37:55 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWegdHLxnk+G2UuyyaQNLfNUqFi8T+8UmWlwVqNpgituflmmes1iX1nQRt3G0dOspkWQo4s5x6e9EjHTVQFh1y6 X-Google-Smtp-Source: AGHT+IHjpTw2/xC7RKlPETyiuBH5YMAcJ61OoVSdlOS7TJx56AMcI3wqZd2VgNNqZ7B+/CWeUx8N X-Received: by 2002:a05:6102:2322:b0:476:589f:c14b with SMTP id b2-20020a056102232200b00476589fc14bmr5064869vsa.6.1711370274773; Mon, 25 Mar 2024 05:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711370274; cv=none; d=google.com; s=arc-20160816; b=w+DsRQSRmcd5feilXDDoZ5awe1D3Nc3rFnrYVNoJNv2U46zKUZmlbPOj38Q31bmSgF Titn/h7gku1i41pgOVhkkJh+IvVGb/Yy87aWxzjG9WFQgsL5j7QV8Y7G+KegddWI5h+F n0bc82hbHPrdKgQP3zNXuPFxGr+EUVrqSmP/LEfLb/2EGTGcuIc2XSzj1nPZ2DYNVZk2 XqZBdZF1rUSJ8mv6EjUAv2sY0ifrDZc1+WpiWPD4g19+zeBHWL3dnyCNGKwm9AbSC0Yj UcVDZT53aTQ5PSXpiZ7B1bDpMqo8b0t7nZcawtAYgJuKFy9o7jVdBOZyKPzAHMXsAfQ+ 6E9Q== 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:to:from :dkim-signature; bh=4aVB8aQfFHBTbOCLmq+XJCLN+ZOpZZJ/7MtfrbF8pCw=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=aFsQBic7bUNeEwwhHQLAOsTnzDvs+K4D78qkfSX8YLWlDBH0CZwch2MGThHjbTdIx0 0S61/ckuhqI4JBattceUaz1qVPzssXBJaxe4Uw2x1Pb5LyNp6fB8OyhyM+BEzFGTmXvo wXIwr0sm6wMNnZvLSUuspENL3+YZ5nhdLpaTKS6pJM9rH+4zsFnGXDTlWB9wM0F8WwNg 6X2cuijyXJSUCTJq26G8Lx/niJRztQoPTMKGoqH3DCQdMhiXrS5Isr/8Dzar7qmlkH1C 3JZprfmXTx1DaSpT2McXEmH4qgLa5wKAb0mOHD/4468Qei0RsdGfGWd0+4i+ZbbmpaSD FT3A==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=w9yF66Wd; 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 i13-20020a05620a0a0d00b00789efde4910si5185097qka.163.2024.03.25.05.37.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 05:37:54 -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=w9yF66Wd; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rojYX-0002JX-IL; Mon, 25 Mar 2024 08:36:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rojYU-0002Ht-9n for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:58 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rojYS-0005dd-7v for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:57 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4148c650bc7so151855e9.2 for ; Mon, 25 Mar 2024 05:35:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711370154; x=1711974954; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=4aVB8aQfFHBTbOCLmq+XJCLN+ZOpZZJ/7MtfrbF8pCw=; b=w9yF66WdwsE+kArJ66Pb6xkLwB9g3nGczm/cJOZDvW3tqOlgy2/rqEy0AI97C0k7FN ku+y1cYcrX3YZKsOafkDsbsBU5+9iLOT7JXENrI2scuhD2qwswe7s1rOyRsHhypfNhWR sCFbB9gSQ3ww2G+7nnXmm2xV59Ob9v3LPpPxRNBhCQM+gwCQV4RiZG1mVhKqMllR+n9C NUMx159Sw3REk/2cPJ97CE93mHMmcsWkbAzdOd0TowosL2jHYgh+H5yPBWLJI31aoynk FOfC3K+8YtCIWQNxMozhxuWD0U42oSxr6zNhF4ubTCCdDtJA9p1WscDOk214N5/lDPt9 7csQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711370154; x=1711974954; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4aVB8aQfFHBTbOCLmq+XJCLN+ZOpZZJ/7MtfrbF8pCw=; b=d6Quj62dOn56qTzFKFeLTeQtfGn60wrTSfwy5dhTb4h9jQmpdA2sNP7VkB4vfOYyBA nC2ehMlecMynk/appXtEZOIqHbVIplBuT7KX4Cxqqxq/FeSUpx32hbSy0Rziqnhfi+9L PWb6WG36xCKs358zGKPF/r5Zp7/+pfy/Lv+y4dZ1o2XZgBtpzbvV0RiYsddTqAXMA+oo dR98RK8aQNbFeOFrQ1xRvTsk6/gYU6Hm/9JxFZhEoVVkKXPCyVxlE7PVeoZ6ek2gKpyT HLPVcBLb75QcG88Vi50ABMJmLhslU1+R0avkG8b8+IBsF9jBibv1kPwdgj/TemnGFXWo yBbA== X-Gm-Message-State: AOJu0Ywmm4334gY3/SMbUZgk9MGq3hB2Yvg3667z6BY0Agl9ovzHhVKb zUOxgzATmTF0v0EMpLIWvZkbpCZk7nKD/v+UazG7pHI0P9OyTYqxojNQGSLPDzC5sERjte7jQ2o j X-Received: by 2002:a05:600c:1547:b0:413:ff10:cee with SMTP id f7-20020a05600c154700b00413ff100ceemr4997308wmg.13.1711370154700; Mon, 25 Mar 2024 05:35:54 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c339300b00414041032casm2303877wmp.1.2024.03.25.05.35.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:35:54 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 6/7] tests/unit/test-throttle: Avoid unintended integer division Date: Mon, 25 Mar 2024 12:35:49 +0000 Message-Id: <20240325123550.1991693-7-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240325123550.1991693-1-peter.maydell@linaro.org> References: <20240325123550.1991693-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.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 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-bounces+patch=linaro.org@nongnu.org In test_compute_wait() we do double units = bkt.max / 10; which does an integer division and then assigns it to a double variable, and similarly later on in the expression for an assertion. Use 10.0 so that we do a floating point division and calculate the exact value, rather than doing an integer division. Spotted by Coverity. Resolves: Coverity CID 1432564 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-id: 20240312183810.557768-7-peter.maydell@linaro.org --- tests/unit/test-throttle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test-throttle.c b/tests/unit/test-throttle.c index 2146cfacd36..24032a02667 100644 --- a/tests/unit/test-throttle.c +++ b/tests/unit/test-throttle.c @@ -127,13 +127,13 @@ static void test_compute_wait(void) bkt.avg = 10; bkt.max = 200; for (i = 0; i < 22; i++) { - double units = bkt.max / 10; + double units = bkt.max / 10.0; bkt.level += units; bkt.burst_level += units; throttle_leak_bucket(&bkt, NANOSECONDS_PER_SECOND / 10); wait = throttle_compute_wait(&bkt); g_assert(double_cmp(bkt.burst_level, 0)); - g_assert(double_cmp(bkt.level, (i + 1) * (bkt.max - bkt.avg) / 10)); + g_assert(double_cmp(bkt.level, (i + 1) * (bkt.max - bkt.avg) / 10.0)); /* We can do bursts for the 2 seconds we have configured in * burst_length. We have 100 extra milliseconds of burst * because bkt.level has been leaking during this time. From patchwork Mon Mar 25 12:35:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 782314 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e01:0:b0:33e:7753:30bd with SMTP id p1csp1146453wrt; Mon, 25 Mar 2024 05:36:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWLGPMcixC75r1XWHNnpP2A/EJavawFdQORH93Sj24dXuWQc/ZYp7vtL8glPMa1QKAlZzTZLliEY/ktO0vQHR4Y X-Google-Smtp-Source: AGHT+IHZfd/VDe/CacXeawByebZFJaKEhShb6tpMUU80eYoXZIZNbvBOxtOX8XcXUKpRDFm2xvG4 X-Received: by 2002:a25:ce4b:0:b0:dcc:67a7:430 with SMTP id x72-20020a25ce4b000000b00dcc67a70430mr4908577ybe.15.1711370194774; Mon, 25 Mar 2024 05:36:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1711370194; cv=none; d=google.com; s=arc-20160816; b=bOhhcEdyTlOPY3qSjoXrmrXaCiSnBIdjfOUYN3999lvO2kwAIQZWYErdiZ3I79s7hF s4WwHpJcY6AMzMWO8LIEXNcNwFnEVWYOydv00gMCvuVn5P8RNYegNq2plrqgj8jlCaZy bMW67RW++N6ruT51POqqDfPiBM79PBLc+Bb+9zbSpVxSWfqH6YuhUQWBLFls7ZRALrzt bjTy8IroHDTVfa1w107LC6cloxtcuPL8iVY42LzdIz5AG0ETpCTGRCe3wijpF0+Dfeoh pIz9YuFWKRHf+gTAK8RwZ8cc56ZHTJRxB4WyrFBeWRZq/42Y//oyGdwbfDlCoUow1PGw j/jQ== 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:to:from :dkim-signature; bh=/WSvWBDSQi9Zqsw2htT0Fim8jLY3dFWtGJXr5FhGHxs=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=w+MVlgURwU/YDDeFjAGxb+KBRlOkNQoQHMGpdPEueUOXXelLiZ5yQOhMdoaSB/tbzD YrT97rzSFpvwDFQBJyVEZMxP7ySAMxGxfxjt0piRRrLUAF0/YzGMwMXL/Py0IyeRIhSw IRxQlKuDV77MSlsh+ZtlR3UlUDFcA813TYl2X7L1Bp2Fop9ZnCFxgPu625p13nVAX3Pr FC2tAHVzWrJmg1g9h/SdR2XBJ4zZUG9Ugv9JF3tIg7u5C2VKSwfhlEdP+g5j1QaVdY/D Lz2Ck0l1uR8VdAIX9Chp6UHnD55BgtDzQMSuVEiX6IVQ21H9q9AyYuDmqkIEe1NFjEVY 2YAQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BayrhtsB; 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 gv9-20020a056214262900b006968b2d1f3dsi2428383qvb.414.2024.03.25.05.36.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2024 05:36:34 -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=BayrhtsB; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rojYY-0002K7-B1; Mon, 25 Mar 2024 08:36:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rojYU-0002I0-FN for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:58 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rojYS-0005dr-Ky for qemu-devel@nongnu.org; Mon, 25 Mar 2024 08:35:57 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-341cf77b86dso587407f8f.2 for ; Mon, 25 Mar 2024 05:35:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1711370155; x=1711974955; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/WSvWBDSQi9Zqsw2htT0Fim8jLY3dFWtGJXr5FhGHxs=; b=BayrhtsBTCfrZbhVKJa0LFq58Iqk9wuEYLr/pQ9qBg4xQXhLN02zQFToiNK/7cvkDy W75XTh6XxBkBZRyWBBDVpMgEbt00NTUxZ3NP8vx6Abfs1Od7iBp8aqyhijDjczgIjKH8 5tc7iGfwv+nb6OrJQOmCaUihiUxT08icF/1LMLtBMxwvu/E6HpfXPV8Vvf1KtKNfUu/a VBUO17rCZggcaMxy6gkgoEXv6Uob9PszU8Q2pP85F1fb/TDQX12gXAUkcgc8h5KT+5e0 sPjdXPQxqI/YEJzsYDqeP4GcTkJiiGEyi3FG93sRZ89JBUVBC3am+7jXo2LwfuQPl3Ce PsaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711370155; x=1711974955; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/WSvWBDSQi9Zqsw2htT0Fim8jLY3dFWtGJXr5FhGHxs=; b=hk5FA0mUFFi7OGm3vu9aTAQvcXY4k73CmzurE+sGKzX/q/MM9X6dUCTdiUk83qBqwV ILRCSAAYXAHdhltxsikPj9Hf4uZ/ZozVNhsaCmtSVG5YsX4wV44LWGyoTxDLX5w+9fSY nAG37DEM5oKKhXthO44mC65SP/Hr3t61yW3OqglWtw3wP+pX7mxTe6m5Y21KFZANewnU /qz4PzJbFLMHUYUh7d1Ipnf6WbOZGc9ACQzlM1S32tQ6wG/1tp20W4mfb406ceYZEECl Oxc493s/Nd41NcvfzJxNgZaZOunwwNuNAIM4ktQGxv+TMZp2gY/noHcH+dYkdyHAiQSZ Umwg== X-Gm-Message-State: AOJu0YzpnZnOxF4Pmn8FSFiTLNILTtz+CirmvZ642SrU4uVoBCHpMZMf knnyoq2sK7kD1/R6n9DtYBfucNbquM/Ew7toAUPPjaBEbyMEzu5m08sWtDYWiyULeCc3C+DKGm1 s X-Received: by 2002:a05:6000:dc8:b0:33e:8b95:b350 with SMTP id dw8-20020a0560000dc800b0033e8b95b350mr6243896wrb.7.1711370155091; Mon, 25 Mar 2024 05:35:55 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id o19-20020a05600c339300b00414041032casm2303877wmp.1.2024.03.25.05.35.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:35:54 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 7/7] tests/qtest/libqtest.c: Check for g_setenv() failure Date: Mon, 25 Mar 2024 12:35:50 +0000 Message-Id: <20240325123550.1991693-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240325123550.1991693-1-peter.maydell@linaro.org> References: <20240325123550.1991693-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.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 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-bounces+patch=linaro.org@nongnu.org Coverity points out that g_setenv() can fail and we don't check for this in qtest_inproc_init(). In practice this will only fail if a memory allocation failed in setenv() or if the caller passed an invalid architecture name (e.g. one with an '=' in it), so rather than requiring the callsite to check for failure, make g_setenv() failure fatal here, similarly to what we did in commit aca68d95c515. Resolves: Coverity CID 1497485 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Reviewed-by: Thomas Huth Reviewed-by: Philippe Mathieu-Daudé Message-id: 20240312183810.557768-8-peter.maydell@linaro.org --- tests/qtest/libqtest.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index f33a2108610..d8f80d335e7 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -1814,7 +1814,11 @@ QTestState *qtest_inproc_init(QTestState **s, bool log, const char* arch, * way, qtest_get_arch works for inproc qtest. */ gchar *bin_path = g_strconcat("/qemu-system-", arch, NULL); - g_setenv("QTEST_QEMU_BINARY", bin_path, 0); + if (!g_setenv("QTEST_QEMU_BINARY", bin_path, 0)) { + fprintf(stderr, + "Could not set environment variable QTEST_QEMU_BINARY\n"); + exit(1); + } g_free(bin_path); return qts;