From patchwork Sun Feb 14 18:39:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Vincent_Stehl=C3=A9?= X-Patchwork-Id: 1440536 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=laposte.net header.i=@laposte.net header.a=rsa-sha256 header.s=lpn-wlmd header.b=EcsfbMO5; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DfPQL0Rklz9rx8 for ; Tue, 16 Feb 2021 00:02:17 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 752728270D; Mon, 15 Feb 2021 14:01:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=reject dis=none) header.from=laposte.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=laposte.net header.i=@laposte.net header.b="EcsfbMO5"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6387E826A6; Mon, 15 Feb 2021 09:24:49 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from smtp-outgoing.laposte.net (smtp-outgoing-1703.laposte.net [160.92.124.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3EDB9823B5 for ; Mon, 15 Feb 2021 09:24:46 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=laposte.net Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=vincent.stehle@laposte.net X-mail-filterd: {"version":"1.2.2", "queueID":"4DfHG318Vpz7t7b", "contextId":"7e8fb828-1fdd-4a80-ad1e-75d08c2820bc"} Received: from outgoing-mail.laposte.net (localhost.localdomain [127.0.0.1]) by mlpnf0102.laposte.net (SMTP Server) with ESMTP id 4DfHG318Vpz7t7b; Mon, 15 Feb 2021 09:24:43 +0100 (CET) X-mail-filterd: {"version":"1.2.2", "queueID":"4DfHG271tcz7t7L", "contextId":"1bafc5bc-9c88-4edf-8efa-8d351e88afb3"} X-lpn-mailing: LEGIT X-lpn-spamrating: 40 X-lpn-spamlevel: not-spam X-lpn-spamcause: OK, (3)(0000)gggruggvucftvghtrhhoucdtuddrgeduledrieejgdekiecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfntefrqffuvffgpdfqfgfvpdggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddtnecuogfvvghsthdqkgegudelqdfumhhtphfkphdqnfculddumdenogfvvghsthdqkgegudelqdfumhhtphfhrhhomhdqnfculddumdenogfvvghsthdqkgegudelqdfumhhtphfjvghlohdqnfculddumdenucfjughrpefhvffufffkofggtgfgsehtkeertdertdejnecuhfhrohhmpeggihhntggvnhhtucfuthgvhhhlrocuoehvihhntggvnhhtrdhsthgvhhhlvgeslhgrphhoshhtvgdrnhgvtheqnecuggftrfgrthhtvghrnhepteeivdehieejtdfgledvgffhvedtveejhefftdeukeeuieduudetjeektdeuffetnecukfhppeekkedruddvuddrudegledrgeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehhvghloheprhhomhhurghlugdrsggvrhhgvghrihgvpdhinhgvthepkeekrdduvddurddugeelrdegledpmhgrihhlfhhrohhmpehvihhntggvnhhtrdhsthgvhhhlvgeslhgrphhoshhtvgdrnhgvthdprhgtphhtthhopehsjhhgsegthhhrohhmihhumhdrohhrghdprhgtphhtthhopegsmhgvnhhgrdgtnhesghhmrghilhdrtghomhdprhgtphhtthhopehvihhntggvnhhtrdhsthgvhhhlvgeslhgrphhoshhtvgdrnhgvthdprhgtphht thhopehuqdgsohhotheslhhishhtshdruggvnhigrdguvg Received: from romuald.bergerie (unknown [88.121.149.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mlpnf0102.laposte.net (SMTP Server) with ESMTPSA id 4DfHG271tcz7t7L; Mon, 15 Feb 2021 09:24:42 +0100 (CET) Received: from radicelle.bergerie (radicelle.bergerie [192.168.124.12]) by romuald.bergerie (Postfix) with ESMTPS id E92A43F3AE17; Sun, 14 Feb 2021 19:39:19 +0100 (CET) Received: from vincent by radicelle.bergerie with local (Exim 4.94) (envelope-from ) id 1lBMIh-0001QO-MC; Sun, 14 Feb 2021 19:39:19 +0100 From: =?utf-8?q?Vincent_Stehl=C3=A9?= To: u-boot@lists.denx.de Cc: =?utf-8?q?Vincent_Stehl=C3=A9?= , Simon Glass , Bin Meng Subject: [PATCH] virtio: fix off by one device id comparison Date: Sun, 14 Feb 2021 19:39:04 +0100 Message-Id: <20210214183904.5432-1-vincent.stehle@laposte.net> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=laposte.net; s=lpn-wlmd; t=1613377485; bh=OijoBpxqhCkLr+HqDMuwunhj1qmdkRkGQDB4yfo/cm4=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Content-Type:Content-Transfer-Encoding; b=EcsfbMO5p1RfoK1oBlAssRw9zLznG6dZyRplbGWdQBZ6qrvtZjMBhMVCBsBInO9/D1tLB+5/8gWqXvHUANutD03gTaJbe4zeKWS3ON5W6GdEkGOCxc3nZrgMFFJ+dyKcd/QDOskdtf8SdLaoavv6XdTjXuc0htGKbFBAaZWgLgDbn+WdF6Ev0Pj1MLQJRHKfbRqXiZeeGboHUnY90OBcvVmc3xozFitq+FDSo1gzv9fXfWOEIhDSAi74ldo0w6K38xnBLDRaXZvzxcVdVfG9OMiDkard2l3ghn94Pam6Dqq85PLxz8rFH4HXOmtuQWxL6k23CLcol/Tpv1UB6bH/zw==; X-Mailman-Approved-At: Mon, 15 Feb 2021 14:01:54 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean VIRTIO_ID_MAX_NUM is the largest device ID plus 1. Therefore a device id cannot be greater or equal to VIRTIO_ID_MAX_NUM. Fix the comparison accordingly. Fixes: 8fb49b4c7a82 ("dm: Add a new uclass driver for VirtIO transport devices") Signed-off-by: Vincent Stehlé Cc: Simon Glass Cc: Bin Meng --- drivers/virtio/virtio-uclass.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/virtio/virtio-uclass.c b/drivers/virtio/virtio-uclass.c index cf2cfaef2cf..0379536c542 100644 --- a/drivers/virtio/virtio-uclass.c +++ b/drivers/virtio/virtio-uclass.c @@ -227,7 +227,7 @@ static int virtio_uclass_post_probe(struct udevice *udev) struct udevice *vdev; int ret; - if (uc_priv->device > VIRTIO_ID_MAX_NUM) { + if (uc_priv->device >= VIRTIO_ID_MAX_NUM) { debug("(%s): virtio device ID %d exceeds maximum num\n", udev->name, uc_priv->device); return 0;