Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1562350pxb; Tue, 8 Feb 2022 22:23:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwbrPjWE/I2j1fBO95QJNKadc4OFPAZ/R18lY2BNtzZP9HCy+SSDaEaWxgfUAmXCH9FEcDI X-Received: by 2002:a17:90b:1bcc:: with SMTP id oa12mr880455pjb.93.1644387815829; Tue, 08 Feb 2022 22:23:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644387815; cv=none; d=google.com; s=arc-20160816; b=K2Mwo9Ij5LmidnsvoM6I9ktbRVKJO7SzUASbxalw/Br9ibgo3Huty6tcoQH/Mzwlk6 ldxe/PXfs0Po5FWePy2rvg0Y3e/gheknfHSgeOkUn9Uh2rH6Te2EqTkirwZbXfIIzzFm kBj6P7tAqTzGiUpBaKp3nDq3tsWwjHv3Rk80BUOa2v9aBiIoYKnObAJDjpVUNGnMPNo3 RqfdaZ9CkDQCoFUXqCiao4AxZ6vCCG7X99l0Xall/clMiu4wNArsDoeAPD7J0VheTyk1 rSvabLYkes/5cI4R/zbqJ+VTEkmAX46hsffUcbYLaZIiRjFr2oT5k/2aCkcRCsuReI5x Lf+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Obmz7GY8u9vQs+YZNmAyBMHd5Z/aDQn2UM2+eLFLCC4=; b=QKqsBkIpBv4+uC34PbZtMAENHhji3coybEMi0oHrXLMRFh/mXALVJeJyRkKtWbXLm4 dACYNQsM2fMHhzvfRsWxfWV0lSIQJEQvYNQf/FcvOLvJGeJCdZEKyuw/Ust+RiZwWt3P wx/iHATBNdr1wLW7l9ztXWKAs+G9jaLg7qzgx4H34uKsz9yQTgTnRjFCA6LlQQL/Ow6h 2fydjzK8ulqo3ndmBGZV5X4IylmrRP9jnCFm8CrHA1acXUCcbuRTQpxI/Mb2Zb4LBpyg s+RIXdi8y6y8/ECRt5c8cw3UEeorrmphS/yaPosmisPgAo+xz43q492b9jykU+s58MNC Le0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xkUbl18p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id pc6si5181271pjb.3.2022.02.08.22.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 22:23:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xkUbl18p; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 71A33E01CE43; Tue, 8 Feb 2022 22:04:08 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1386372AbiBGLtr (ORCPT + 99 others); Mon, 7 Feb 2022 06:49:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386692AbiBGLfY (ORCPT ); Mon, 7 Feb 2022 06:35:24 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14237C043181; Mon, 7 Feb 2022 03:35:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 98659B8112C; Mon, 7 Feb 2022 11:35:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDEBEC004E1; Mon, 7 Feb 2022 11:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233720; bh=ltgwrwtKt8xHd3CXYRwUOLL0p3DAs3UWKiWzsRUVJi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xkUbl18pbkIbI+wYslySfQ06iNueEAuDHHucBzeWTdgqP/iW0QWTtUuf429dsNyHc FSbQCFj9wdKZCwIUvZ3bf3h/yuzHlp2aBG13KfwQRYCMGVj+6K4RxCBIpN/nVnS13r BlNGQpOYvKMopKCy0udvqV59ftgoEbb7f8Pn7LnM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Haiyue Wang , "David S. Miller" Subject: [PATCH 5.16 100/126] gve: fix the wrong AdminQ buffer queue index check Date: Mon, 7 Feb 2022 12:07:11 +0100 Message-Id: <20220207103807.532064652@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haiyue Wang commit 1f84a9450d75e08af70d9e2f2d5e1c0ac0c881d2 upstream. The 'tail' and 'head' are 'unsigned int' type free-running count, when 'head' is overflow, the 'int i (= tail) < u32 head' will be false: Only '- loop 0: idx = 63' result is shown, so it needs to use 'int' type to compare, it can handle the overflow correctly. typedef uint32_t u32; int main() { u32 tail, head; int stail, shead; int i, loop; tail = 0xffffffff; head = 0x00000000; for (i = tail, loop = 0; i < head; i++) { unsigned int idx = i & 63; printf("+ loop %d: idx = %u\n", loop++, idx); } stail = tail; shead = head; for (i = stail, loop = 0; i < shead; i++) { unsigned int idx = i & 63; printf("- loop %d: idx = %u\n", loop++, idx); } return 0; } Fixes: 5cdad90de62c ("gve: Batch AQ commands for creating and destroying queues.") Signed-off-by: Haiyue Wang Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/google/gve/gve_adminq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/google/gve/gve_adminq.c +++ b/drivers/net/ethernet/google/gve/gve_adminq.c @@ -301,7 +301,7 @@ static int gve_adminq_parse_err(struct g */ static int gve_adminq_kick_and_wait(struct gve_priv *priv) { - u32 tail, head; + int tail, head; int i; tail = ioread32be(&priv->reg_bar0->adminq_event_counter);