From patchwork Sun Oct 6 17:21:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 175289 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3299318ill; Sun, 6 Oct 2019 10:32:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzRzEa0kx9MNptB+KdWsJh6ZGFq/oZfwtKGCpP6HXK5aNdq0F6FF3bxexKqJyVmyfd/ey0y X-Received: by 2002:a50:f703:: with SMTP id g3mr25329521edn.43.1570383123860; Sun, 06 Oct 2019 10:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570383123; cv=none; d=google.com; s=arc-20160816; b=ZFSjZwR8cLTw31/Bpz8f/SykyjX8/t75BWhFaxl8VO861hwOn+3VztBHLX2eQ1/V1l 4eWqKKj9uhM8Pxr7AWYr8cR/4+Sl+0xJIy1cMfAR4ikcD3+dilXPdsP1Qx66UBvGX5M5 28/y8nDfder5Dr/0Q0/6gz8d5Z68HqAlRcnbXxr6EojUVXkvlXbNVD/L17tgH9BmdPm+ /OOpFGb6J9DHikyaWKQPLOaOuHJdOYmJVM7xzb+UPiNP9c+RKEGKifEJybm8PSwCeLCZ 1HzJyDV+VI//Ddv6fs9BoWNw3nr6N29e3o/C/VH+YBjYH1guk1hxnUr1HIhtYMA12kXe IY9A== 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 ci22si5881803ejb.162.2019.10.06.10.32.03; Sun, 06 Oct 2019 10:32:03 -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 S1729088AbfJFRcC (ORCPT + 27 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 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,