Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EBCD5C433EF for ; Tue, 16 Nov 2021 02:22:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC84060E0C for ; Tue, 16 Nov 2021 02:22:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345271AbhKPCZL (ORCPT ); Mon, 15 Nov 2021 21:25:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:53204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237297AbhKORYw (ORCPT ); Mon, 15 Nov 2021 12:24:52 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 597A36325B; Mon, 15 Nov 2021 17:16:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1636996581; bh=XtJPR4riwDK2kuUfIoCJE2QBr608Yr37zv7SsAGK98M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z//waNmkrvQvRWNPzGe3NY5QkmOrdII1quLAot6JLvCrf5uMSp2QBokiz/EyTArQe WMf66Qf+f5yRY6TaidQFM7qhjSPvSSZKZ2iFpLWDxP/HD9S6j5ZyDeL1AGL3d6IYxd VPmHLMgCy1cEpzjUVJtdJEpyrqVAF4EV/bvI3KoQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mauri Sandberg , DENG Qingfang , Florian Fainelli , =?UTF-8?q?Alvin=20=C5=A0ipraga?= , Vladimir Oltean , Linus Walleij , "David S. Miller" , Sasha Levin Subject: [PATCH 5.4 192/355] net: dsa: rtl8366rb: Fix off-by-one bug Date: Mon, 15 Nov 2021 18:01:56 +0100 Message-Id: <20211115165319.977907921@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211115165313.549179499@linuxfoundation.org> References: <20211115165313.549179499@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Walleij [ Upstream commit 5f5f12f5d4b108399130bb5c11f07765851d9cdb ] The max VLAN number with non-4K VLAN activated is 15, and the range is 0..15. Not 16. The impact should be low since we by default have 4K VLAN and thus have 4095 VLANs to play with in this switch. There will not be a problem unless the code is rewritten to only use 16 VLANs. Fixes: d8652956cf37 ("net: dsa: realtek-smi: Add Realtek SMI driver") Cc: Mauri Sandberg Cc: DENG Qingfang Cc: Florian Fainelli Reviewed-by: Alvin Šipraga Reviewed-by: Vladimir Oltean Signed-off-by: Linus Walleij Reviewed-by: Florian Fainelli Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/dsa/rtl8366rb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/dsa/rtl8366rb.c b/drivers/net/dsa/rtl8366rb.c index 7f731bf369980..d047004360615 100644 --- a/drivers/net/dsa/rtl8366rb.c +++ b/drivers/net/dsa/rtl8366rb.c @@ -1264,7 +1264,7 @@ static int rtl8366rb_set_mc_index(struct realtek_smi *smi, int port, int index) static bool rtl8366rb_is_vlan_valid(struct realtek_smi *smi, unsigned int vlan) { - unsigned int max = RTL8366RB_NUM_VLANS; + unsigned int max = RTL8366RB_NUM_VLANS - 1; if (smi->vlan4k_enabled) max = RTL8366RB_NUM_VIDS - 1; -- 2.33.0