From nobody Sat May 11 21:50:35 2024 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1711037023; cv=none; d=zohomail.com; s=zohoarc; b=Px/SBQz+MtmK68m47ywJMrETH4My1nEzvzdpdlRk/s4gA/FLJPpvPkdIKUpKZEc6E+Oi+WLfJeFv4pxEGSiOWQ1PuJkn3GGjE+c+mImmX6L9bEaWhd+YeLkNudn39jNtmufadsCg1OozwFCiycC6JIGrEBEX0BTvfSOG1xJx1Mg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711037023; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Qb6T0wX/a0zoWU83voW1zu0dyWTiTnln4IKFAYcZEIw=; b=lL35AaZAEerH7/VSRl11p7whsWf9TbiZ6SVb5s1ntJuarSNZIFqqtFBgIOAqjv7PkczTIh658i+7lxJAhFhaKD83OB0b00B5EvsYKmcioEZ62L0TCOBkYtgEGRt3ro5HWpLa41EyPwWEZgBOx4+sDESlofnag29mqKp8S22XW/U= 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 1711037023244494.0195536816659; Thu, 21 Mar 2024 09:03:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rnKsZ-000267-Cm; Thu, 21 Mar 2024 12:02:55 -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 1rnKsL-0001pm-21 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 12:02:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rnKsJ-0005bF-34 for qemu-devel@nongnu.org; Thu, 21 Mar 2024 12:02:40 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-683-gzpTJzI3OaK3rCZM01VS9w-1; Thu, 21 Mar 2024 12:02:33 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CAC5B803C8C; Thu, 21 Mar 2024 16:02:16 +0000 (UTC) Received: from corto.redhat.com (unknown [10.39.194.108]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE5A03C54; Thu, 21 Mar 2024 16:02:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711036957; 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; bh=Qb6T0wX/a0zoWU83voW1zu0dyWTiTnln4IKFAYcZEIw=; b=QNVsPVM6vO96Ml91ykSl4BuBpv6QEMmgE9S0XzvSD6Elh+VXlwS1FWvAkp365MXxWNWFM0 zUstCvxti7n4yExZrdU+9iEUGj8OntDYEBqXTMI0C67AQgt6MNXODyKaQhb6NmHuvEzRq4 ABYCzlHS6Y085aQATork94k/IR3TOZo= X-MC-Unique: gzpTJzI3OaK3rCZM01VS9w-1 From: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= To: Glenn Miles Cc: =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org, qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH] misc/pca9554: Fix check of pin range value in property accessors Date: Thu, 21 Mar 2024 17:01:54 +0100 Message-ID: <20240321160154.901829-1-clg@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 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=170.10.129.124; envelope-from=clg@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.372, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1711037024242100003 Coverity detected an "Integer handling" issue with the pin value : In expression "state >> pin", right shifting "state" by more than 7 bits always yields zero. The shift amount, "pin", is as much as 8. In practice, this should not happen because the properties "pin8" and above are not created. Nevertheless, fix the range to avoid this warning. Fixes: CID 1534917 Fixes: de0c7d543bca ("misc: Add a pca9554 GPIO device model") Cc: Glenn Miles Signed-off-by: C=C3=A9dric Le Goater Reviewed-by: Glenn Miles --- 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 778b32e4430a8b618322c26b1b185ed3ead97cc4..5e31696797d9564666ece6fe177= 37ee2a9733e96 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.44.0