Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3376071ybp; Sun, 6 Oct 2019 10:34:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmtislxMaKOFhog55XbI5kvVhqcB0cmuP8vDJDAyljBa9dfXvaJ0TNOgz2XIXMW9uppD1x X-Received: by 2002:a05:6402:1426:: with SMTP id c6mr26319297edx.53.1570383244389; Sun, 06 Oct 2019 10:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570383244; cv=none; d=google.com; s=arc-20160816; b=MgHLc2nsu5lQbJlKy8MyK/7fQJwphSuBnwri+mH/ZM84ZSlx124/wZiIFutfqXOZiH C0xpFaYu+gjPhUjhVzch8BXxuR8Ed7aiEvEEwWBOb2uS9v2YoFPdNYAhAmjLJaTTd5IS 2W1hHbqIaTl2wSSpJtHyTnRa+NjItjVokoCUxiUaumWpUWvQ5M1zNuD12gfmFlSagqH0 dvYDwSWXc9qsPy6fq6KA3ngx/l3V1W3vnwSYqZFzXEaxT8M7zmRGAd/tmublAEZCh+4q r1x6Wrm22IDqxY/R+YE0ridDKoHVAHEqxgEmIEayX0BWeEHSjigs3ujuXN83BQAXM3Rm sCaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0X4PyE+/A0pzc0nrYoqO3ss0n4+zHg2FYbq6rwTnoCY=; b=Q8ETkh3LZ07oFHDjLZM/wVc5uXooWDD2x1gNVDpLsw3GN2SRcf1rilLdM1VGfRh2yI cleGF/4AlevVpw7JBJKRe2jP9Yy3Dm9CNRMMG/3fK/4OwimOch1prmNF0/Nm5gKI9ZJl P1ZSKL12U/s5v01r+HCIyt29dYYzpvQGWV7grwQ5oRz1WKLzpc/+cTfg4qQ4O9AgGkDK mR/DGKexVAWtm+PKj35RucWlEG4ZuabPcXTkIAOEV8LKgTa3ZItRWo6yKqXtZCjmP/9R r4R3k78/el1F35yGmaAu8/OUHbN40Ok7t/y8qfx97ox9Q1KoxEbzLIspPra/82WqwcKn rcwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rSsbawUN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f20si6620422edm.365.2019.10.06.10.33.40; Sun, 06 Oct 2019 10:34:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rSsbawUN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729073AbfJFRcC (ORCPT + 99 others); Sun, 6 Oct 2019 13:32:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:58350 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729060AbfJFRb7 (ORCPT ); Sun, 6 Oct 2019 13:31:59 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A7EB02080F; Sun, 6 Oct 2019 17:31:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383119; bh=qbJambDLBU2iCC1IS1jCXXoXh7F8TMycRq4h3giH+D8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rSsbawUNn75B0DOQpHEks7oYh2Vd27Ad+TYoe0Q8Ei0Z2QGaRjJkOypiZVzc1UXsf flvXsZXE+t8bwqvP0oddjI+WaliWYNN1vgJcYeHsIz+1oY8T7FApIfWlXEPG2XHUYh RW/TA/kmb8TtPXJC9tlrWli/57lwJeMFh7GAfTsc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Linus Walleij , "David S. Miller" Subject: [PATCH 4.19 094/106] net: dsa: rtl8366: Check VLAN ID and not ports Date: Sun, 6 Oct 2019 19:21:40 +0200 Message-Id: <20191006171201.248363083@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171124.641144086@linuxfoundation.org> References: <20191006171124.641144086@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Linus Walleij [ Upstream commit e8521e53cca584ddf8ec4584d3c550a6c65f88c4 ] There has been some confusion between the port number and the VLAN ID in this driver. What we need to check for validity is the VLAN ID, nothing else. The current confusion came from assigning a few default VLANs for default routing and we need to rewrite that properly. Instead of checking if the port number is a valid VLAN ID, check the actual VLAN IDs passed in to the callback one by one as expected. Fixes: d8652956cf37 ("net: dsa: realtek-smi: Add Realtek SMI driver") Signed-off-by: Linus Walleij Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/rtl8366.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -339,10 +339,12 @@ int rtl8366_vlan_prepare(struct dsa_swit const struct switchdev_obj_port_vlan *vlan) { struct realtek_smi *smi = ds->priv; + u16 vid; int ret; - if (!smi->ops->is_vlan_valid(smi, port)) - return -EINVAL; + for (vid = vlan->vid_begin; vid < vlan->vid_end; vid++) + if (!smi->ops->is_vlan_valid(smi, vid)) + return -EINVAL; dev_info(smi->dev, "prepare VLANs %04x..%04x\n", vlan->vid_begin, vlan->vid_end); @@ -370,8 +372,9 @@ void rtl8366_vlan_add(struct dsa_switch u16 vid; int ret; - if (!smi->ops->is_vlan_valid(smi, port)) - return; + for (vid = vlan->vid_begin; vid < vlan->vid_end; vid++) + if (!smi->ops->is_vlan_valid(smi, vid)) + return; dev_info(smi->dev, "add VLAN on port %d, %s, %s\n", port,