From nobody Tue Feb 10 02:55:17 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1710268842; cv=none; d=zohomail.com; s=zohoarc; b=NVFiY6NPSAPDT6HJRWJsa2oADg1JlaL1i6znbnPmt90ozDKnX39CEHzgp4U4e1YdkYPTOMVbmxUAk+DyWxif+gtju48wgHP3AQzjBp4m0uLYZqOL2ZNEMxHmrb4LjODPabAAkqVAoXf/GKLPdJbsRUqXHGfd1Ok60W5gQmrBcGs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710268842; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=XxETGuhhBQo6mApLsduj7FC9ZSriYQJnVDPgySwv8KY=; b=OBt2oLQeRRDdhnJIqQdPUx5R5NJ7g+WGsFC5Zg9j2KSTHyYuvVxLdXp7Bsm9eHnYMiLmlJKn+TCwSwxllIvFMisXzoOM+g41fyBx0YaBbIeFMgLU967BXL61ZzVyW6/LONDp+3KB+sT9Opv74xEAYJKCrLV2n/cHC4DvNfoIEtQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1710268842025880.0843998155312; Tue, 12 Mar 2024 11:40:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rk71C-0003T6-1q; Tue, 12 Mar 2024 14:38:30 -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 1rk70z-0003Mh-Ne for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:17 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rk70x-0000cL-0j for qemu-devel@nongnu.org; Tue, 12 Mar 2024 14:38:17 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-41329b6286bso14727815e9.0 for ; Tue, 12 Mar 2024 11:38:14 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v17-20020a05600c471100b00412ee8e2f2asm19836337wmo.9.2024.03.12.11.38.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 11:38:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1710268693; x=1710873493; 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=XxETGuhhBQo6mApLsduj7FC9ZSriYQJnVDPgySwv8KY=; b=FsPkBAIvLRzG7OfBAwYq7BywGOs4oQkJxpOec3xQdU+r7w9IW6pnoXrPZi8UfhD/kR rC9WBfyLpbebc8vANlQzDRJwV7DL7PGDqkiPNcsOCzJ9Kf9gevymKm3ZM7yrYKXW3h1e zfPY9RzR/j2P7YT/PMvkIyP+cXD5qtUUyNAGygsgYpgwhEXia0sVajy3/2mfDp+13H1E XJTNC4is7ehzUG7dLRw4RFVLmn+X7VRo23lPymojV8A0Sa1yAXPEKTqxQ8R7Mtgq34kt zwmEiiJZZQL9TV5Q1sUdPRz6PsGBPH82UW23W6lTUBOZ8MMv7YNl+UKqmK+/+l6hW7AJ YUPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710268693; x=1710873493; 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=XxETGuhhBQo6mApLsduj7FC9ZSriYQJnVDPgySwv8KY=; b=ljKhcpj6spaEvpiFP2Klq7QuaNYMF7J1iUscM/GdcVXjnsD5QswaLO28zs9/TlNxFE Sycf49h9Bu5E1hmfYGsmOchL1/yDBpzKKDjL4TzgDjjFjFEkvSx9eqqUYIKz7+aD3BYP +RRuZxDqZi7zK2FuHsx85DOUKv9G76wtZdq9HIYX2g/uycjT/b3jzhGcACwF3YWQjeCF 0lQIu2ZRhGe9GOs8Qa0GwJtpfBgtL79hDYXEjHr+5/o8/4o8IQwPUUjHwYXqNUzPFi35 lAHXUHDvYv8M4uyvoznAE0h5yjZ5TXhc2x/tin/0jlF8I2T2sgTKiud2UiQvv52nNf9y +5ew== X-Gm-Message-State: AOJu0YyITBebTpbrR6rJA6sEI9CU77Qsz98PEw6uaF1PNXI7D74QGq/X 8wkqMocX6UPxg1cHktKu5WabzFgOeueipRB3LMv+SARtQlHvKJLdMeIEFCVrVlCyQy/gJAHbsiI D X-Google-Smtp-Source: AGHT+IFpuQyr3sxFxbTV1CiCvOn2uKA/ORryDX/H7nR2om000hMsYM5fQNRFGzs0NkVfQe50tLBt6A== X-Received: by 2002:a05:600c:4708:b0:413:2958:e323 with SMTP id v8-20020a05600c470800b004132958e323mr798783wmo.10.1710268693246; Tue, 12 Mar 2024 11:38:13 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH 4/7] hw/misc/pca9554: Correct error check bounds in get/set pin functions Date: Tue, 12 Mar 2024 18:38:07 +0000 Message-Id: <20240312183810.557768-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240312183810.557768-1-peter.maydell@linaro.org> References: <20240312183810.557768-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::330; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x330.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1710268843525100001 Content-Type: text/plain; charset="utf-8" In pca9554_get_pin() and pca9554_set_pin(), we try to detect an incorrect pin value, but we get the condition wrong, using ">" when ">=3D" 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 --- 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, co= nst char *name, error_setg(errp, "%s: error reading %s", __func__, name); return; } - if (pin < 0 || pin > PCA9554_PIN_COUNT) { + if (pin < 0 || pin >=3D 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, co= nst char *name, error_setg(errp, "%s: error reading %s", __func__, name); return; } - if (pin < 0 || pin > PCA9554_PIN_COUNT) { + if (pin < 0 || pin >=3D PCA9554_PIN_COUNT) { error_setg(errp, "%s invalid pin %s", __func__, name); return; } --=20 2.34.1