From patchwork Sun Aug 23 20:59:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 248151 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:522:0:0:0:0 with SMTP id h2csp2056292ils; Sun, 23 Aug 2020 14:00:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDdGO/OjtDmiqSAxfHDZ0NiR5MYRiyBiGNVJxKk7IV1ejmFKUHRP8l7e6n9mc5thhnCwia X-Received: by 2002:a05:6402:1a25:: with SMTP id be5mr2616211edb.62.1598216457107; Sun, 23 Aug 2020 14:00:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598216457; cv=none; d=google.com; s=arc-20160816; b=Qy3Ll6HRRdakI2OoYeTSEux7VNn9tVkybq0pbTyW07jDDxBefTvoB99uWFt7z4VGwe jloWxVwbwresheoxjQZZ8wS/BGEXhfmnq7kfEEuLUP2Jjk8+cHTQkA5b+y5vgUylvZOS VFH9oG8AkikycmlofaVmE3B5MftAtFDS03LRB8X1Lj4Hs0/eo4EZuKI7BAAkxnMmv+B7 6W7yXT9w10YOjcGiM7tJQYmMrZqV/EU2xt/AVMgSOdoVzDOBmQQ7Ea32kVudX19PIwck q12Jj5bpb/VVx6F+lDg49hjFnzQuS0iFNwS15NaKRrPbJxYClt+9pQad5IVlJWaHYfbA 0p4w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=o4o/RWuZSVyt2KxX1fFudlYA+bRugpK9nsAuSbD4TK0=; b=sHD2YS0DsTpmuakSdpqvhWJl8qB6iD2QsAQhv/hOeUWT8YKBZciQrwnK0wReZb+t4k UjgsFrypU1nbU41THpBKHwH/rSAQnruTC/sv24S5WDVrtCUgDMdJmmpforBlDGN5QQpZ 35kzdl09g4/4ecAiiNTJVfNqKNRcUNtPn+qFDkfMcb3nMiWPYndYxFWjH3y2TE1E0oLo nDWtalgdb+d4RePpOdfot+BuizI+8yO+rghDbzMBVo0EwmHsBQYxQpFAQSoudcHGhwLG 5lpK26ehPONNUr4JZVzqBcUWzWFPUgjxWx4jVnvYvMI04JiWJSWHP/BQi2OBTDgDoFXp YhVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XTeKMDZ+; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id mf26si821827ejb.665.2020.08.23.14.00.56; Sun, 23 Aug 2020 14:00:57 -0700 (PDT) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XTeKMDZ+; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726816AbgHWVAz (ORCPT + 9 others); Sun, 23 Aug 2020 17:00:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725995AbgHWVAy (ORCPT ); Sun, 23 Aug 2020 17:00:54 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F61AC061573 for ; Sun, 23 Aug 2020 14:00:54 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id i10so7393911ljn.2 for ; Sun, 23 Aug 2020 14:00:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=o4o/RWuZSVyt2KxX1fFudlYA+bRugpK9nsAuSbD4TK0=; b=XTeKMDZ+OQwHT2AbGK01DqX1gidUgqaTmXRexHXdJQZGSoRCjIZue9zjTKjZlETg7M 19a2rGynO60OWfRIYD78Zc+28nA3giFOatcWM74/Zx1ktNkR46ioHg7c2QJb48EVLL1/ SPPXgHPr8OR8kL8TMwwtVjji2zTh7zLDzYIIqwKl0bHEVPK5BCLmjDd8fDnTclnHYap5 1TbG2eOUuaotfff0vhbgpbu6FlJ1prmd2Cev+B5QWnMkWRV75DDKaLqrk8Dg7q/njn5H UI8dEuw2tI02MRB5lBPFqP/HroJ5u3D8PNaHBDKKTxhS4bVWrgpgkxAxedNXoobzdCSc wI+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=o4o/RWuZSVyt2KxX1fFudlYA+bRugpK9nsAuSbD4TK0=; b=P1tmw3kDUEFtSlXuCtGz/5fKRm/26cLBoHO/ZHnjrBe+NruL1oLGpejZiZK6Gw2kfT g/wjbHUw+GZ89Ax9zDZeqMInKLO17RRPuLDRTtMuohfbz2E6nHJJcfXIUX1q10AHMFUz P1mSc2MG2NXfttyapQKcw34BoZ5YHZO92z2I5SzNHk3lAzKt2IOKhHOiLIcVJYmTR7jt StcIh/xAZwzOuuKg7pgW2VENt9c2VG0YwbZzzt2UDpOLF8LEpigK3kjWTzR9GMvpdtTu TeOht5aYJ6IRr7wvemdpN/SOneh0rIltVDZJWBcD1sjuRDwI8MQ6hzRQcIP8jyjQkxJW oScQ== X-Gm-Message-State: AOAM533SaQHwKgqGAGfVfL4RD0mYCKWFzqOVQr162DTkcNR6+pSKMy3x fSRMVDhQkbnZqWrtdCSKFyDsMg== X-Received: by 2002:a2e:99d5:: with SMTP id l21mr1143354ljj.320.1598216452652; Sun, 23 Aug 2020 14:00:52 -0700 (PDT) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id y9sm1786184ljm.89.2020.08.23.14.00.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 23 Aug 2020 14:00:52 -0700 (PDT) From: Linus Walleij To: Andrew Lunn , Vivien Didelot , Florian Fainelli , netdev@vger.kernel.org, "David S . Miller" Cc: Linus Walleij Subject: [net-next PATCH 1/2] net: dsa: rtl8366: Check validity of passed VLANs Date: Sun, 23 Aug 2020 22:59:43 +0200 Message-Id: <20200823205944.127796-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200823205944.127796-1-linus.walleij@linaro.org> References: <20200823205944.127796-1-linus.walleij@linaro.org> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The rtl8366_set_vlan() and rtl8366_set_pvid() get invalid VLANs tossed at it, especially VLAN0, something the hardware and driver cannot handle. Check validity and bail out like we do in the other callbacks. Signed-off-by: Linus Walleij --- drivers/net/dsa/rtl8366.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.26.2 diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c index 8f40fbf70a82..7c34c991c834 100644 --- a/drivers/net/dsa/rtl8366.c +++ b/drivers/net/dsa/rtl8366.c @@ -43,6 +43,9 @@ int rtl8366_set_vlan(struct realtek_smi *smi, int vid, u32 member, int ret; int i; + if (!smi->ops->is_vlan_valid(smi, vid)) + return -EINVAL; + dev_dbg(smi->dev, "setting VLAN%d 4k members: 0x%02x, untagged: 0x%02x\n", vid, member, untag); @@ -118,6 +121,9 @@ int rtl8366_set_pvid(struct realtek_smi *smi, unsigned int port, int ret; int i; + if (!smi->ops->is_vlan_valid(smi, vid)) + return -EINVAL; + /* Try to find an existing MC entry for this VID */ for (i = 0; i < smi->num_vlan_mc; i++) { ret = smi->ops->get_vlan_mc(smi, i, &vlanmc);