From patchwork Sun Oct 6 17:21:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 175301 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3314322ill; Sun, 6 Oct 2019 10:50:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhoYsxjGB1WTnayrRbwtlobdZsK2S6tFtepjZAX8Je1JUSlM4geAzsr1HsQwPaPDqYsaFd X-Received: by 2002:a50:cc4d:: with SMTP id n13mr25360391edi.5.1570384259142; Sun, 06 Oct 2019 10:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570384259; cv=none; d=google.com; s=arc-20160816; b=dTcY6VyJh9BEa84XHnh89I5QWGPpsAn0bvzGlcBYYzPhu9u0HEAf9Keb1L8CUZOVse NlY/yoOVTrqjuHB+PaIXz12dLnL7jfLkStUQGjqOCw894dWbdKmU5hDoXBfkV/O8KVLn D58Mj937/TuunZLH2ZNNyGsKLbB4v7fdjuWCekQON75WhezmDt7FctlXNPKfk4N3hD8q RdY3/QvIa1+6jGWmMDBS07xS3Zatpd75uilo/pCM7TqaZNs5CkMBs3AjJSIkRsWHGiBy tF++h7m86pdUv3o/ezP8Vz+hU7jWT3VBj1InyO/iFQtb3QSpf42nD7wMijAMMo0hfasG sIAw== 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=LZdii4dIU7MpOY7WqnL4A3AlXZDZyo4A3/dgsvonFPPh4LpdUR7xy3uAk4nRfFWKz2 SnFIooB3P0SdgVnBdpiIgEaKjxIK1zYbpS1uaauaQ+F/4mRe9DCMciK6OoaWBQE2H9u0 5GB+rTQmEhXgbcQ7N4eT+YNJBSofqDyUOMMVmeCPKLQC+73WFqy4z8gtEbaJCHi3Xqy6 8hzM9KGvjapIU2MprEua4SHwJI70elvWemK69aNGA09nJjnFzWbfVdWlq6tGN0nWP/E0 NV7xR70gyOlmWQWhxCYuEmbe5vqrzwvlOJ9KIs4J7KIg+XxpQtJaHDNlscZVE1AJeQGH 7Veg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jgXzoPUK; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 b4si8317777edk.331.2019.10.06.10.50.58; Sun, 06 Oct 2019 10:50:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=jgXzoPUK; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728925AbfJFRu5 (ORCPT + 14 others); Sun, 6 Oct 2019 13:50:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:48972 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727321AbfJFRuy (ORCPT ); Sun, 6 Oct 2019 13:50:54 -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 2ECA02087E; Sun, 6 Oct 2019 17:45:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570383919; bh=qbJambDLBU2iCC1IS1jCXXoXh7F8TMycRq4h3giH+D8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jgXzoPUKmb3HK6NcHyUiM9e4xQKZriUFIrflYM+TJrXHZB3MUuHiotCFqCOLrmiFL sTIxfYWm/WxWSSWgqtQnXs2suSK8RDbycbYSkHx+8uhOA0ObPaNpYOc+502kBRsuV4 GXM6eFMLE/DaafD1+0bqrwzkf+cQXlNIZwjPy0UU= 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 5.3 145/166] net: dsa: rtl8366: Check VLAN ID and not ports Date: Sun, 6 Oct 2019 19:21:51 +0200 Message-Id: <20191006171225.179123080@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191006171212.850660298@linuxfoundation.org> References: <20191006171212.850660298@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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,