Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp188175rdb; Tue, 5 Dec 2023 02:36:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXPAgiu2+a4os0qCsj7xEyYcHuY44D7bfQQCahIsJYDgw0frunHStwcA6ejI4GZBWm/JhE X-Received: by 2002:a05:6a21:3804:b0:18b:ac9:d7c6 with SMTP id yi4-20020a056a21380400b0018b0ac9d7c6mr2043629pzb.58.1701772611883; Tue, 05 Dec 2023 02:36:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701772611; cv=none; d=google.com; s=arc-20160816; b=ShgSXw52jMZ7LhY6gjKYsys30qMGOt/zOK7IjtQaiu26/Mas7Rxu0qTFPfEy2udii+ W0Kwg111RhF9s/jE4BdLS6TJliQ0yC4l1ujVj3rJK82GDNa41uLo7duAjtqptNagMGJ0 udDZ+PR4RW/53ItA0OBqrF+v6bco/G2MqGBVSIeI9bmVfQvGXGTgj7wFXo9vbp68U92i u5tJKu/Ob6om1VHsv2Q7xRYlzomzvFSW8Ib6qKThjVP/c0nZcbltg7yk41OTjTVCIc6O RPBo323ZSHqUo7wu/7GNfTvid5Jsld/0Apm1XpTYAuS3KQ2F/GrzHxZEU9p2wQX0OIgF LtwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=U7nbPSVfDOj9VhJDoGLXG/VirsAsAqdDlwTrxuDOen8=; fh=NoYD4WQZNjSG2Bb9ocssXw4U79pWAZvdivFB0JgByN0=; b=okm0YUA4GGl9QK6NUURlBY6p0CE5VxRXBeW8KH/3JY+zHc21OD8EaYx5JfbS/Hijek CcstWZtH5odQ5LFKHt59ppf+UF67UXQmRPjwtL6lt4dWL7L6jI0B7ORF8QP6ZtDQqhiz Z1K0Ds/IVUsseJIjvYWxh9kF29KPD5I/5mpBOwN3HEx7z5ar9+t/j895k93o8AztK053 NORdBp3bGuZeB+pAiFcflNFFHCLdV+jJd70Ccq0AUSFRXw5lMkOkEqOXHkQcmb2lsire za/mzpjHelKhoka4oqVDYgcc396Lm7oTl74H/CrKw5FqBCf1DD2TZERT/j0GNQ5ANYJ9 UHCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Um9l6Ksi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id u41-20020a056a0009a900b006ce7ad8c148si38204pfg.183.2023.12.05.02.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Um9l6Ksi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 6040B80E6C5A; Tue, 5 Dec 2023 02:36:47 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345016AbjLEKgQ (ORCPT + 99 others); Tue, 5 Dec 2023 05:36:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235103AbjLEKgF (ORCPT ); Tue, 5 Dec 2023 05:36:05 -0500 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 121CA109; Tue, 5 Dec 2023 02:36:11 -0800 (PST) Received: by mail-lj1-x22f.google.com with SMTP id 38308e7fff4ca-2ca0c36f5beso20116271fa.1; Tue, 05 Dec 2023 02:36:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701772569; x=1702377369; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U7nbPSVfDOj9VhJDoGLXG/VirsAsAqdDlwTrxuDOen8=; b=Um9l6KsiWzdIdqGRfXcFgxTFV1AliRaRSqx53gU1RX2tj02PcC/7ZkohK/iHKAE+63 vAeN6OJoV7WQckrYEwbFT+h6MmOXEj7TVy6zTd+6Ixdv7Cfdo7LiKYq/pNFGtGUJHKCP KvH1sRBaJihM4tS8ZZ+QEHTMSy6BnYczODzDste47NQpDcmpa5o2LmEX+Mzdfb41g5dS CdDDPiOFQbamvFyBYY2ERL7AomWem7bgNWJ8nQwO5a02bDld5PAxF/yz/RR6NuEnRZVL 0qImgrX5CwFHMcWjGPDTDMsDW1Jn0r3IGZCRWQ2p05xcBp26cAdPcQd9GgjC17ikSMbi 7rcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701772569; x=1702377369; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U7nbPSVfDOj9VhJDoGLXG/VirsAsAqdDlwTrxuDOen8=; b=IUIIRYxUC7Muy6ze4at2RJJ5RdukLqurQI66acg9WhRz96J+SKOvQG3WGxtxtteSs0 N0lbWnl/cFUSFqi8Nrp4YQNrE6xiabJF2w5LTCNz8Px18Bt9velyYlzpEx9107GQ2A1j tn9atMJk66vVkl35sABRTA2DBliFZ6ZW/Au8WPzNuH6cuKV1DH5xzxao9y7v580fRE9z uzOS8HN4dxGffg7Vo/d/FzZpBgvbvPEgEOfZzp2kv2f3Ojb0t3r4HAJ55sT8jWIQ3BTX x+1CMDzzodg70nq4UivFmK50vlUu7ynPQK4F1PfaSeagtNn/3zvjcen6qq0YUN64PJwg pZOA== X-Gm-Message-State: AOJu0Yxh8mGE2lFMwjEvg1u6QsoIUCn/SBhumJA5UjXXYIqJIoGv3MCJ JEv8H0bH+AtLD0mrxZ7DFYc= X-Received: by 2002:a2e:7c0a:0:b0:2c9:f564:b414 with SMTP id x10-20020a2e7c0a000000b002c9f564b414mr2095991ljc.24.1701772569144; Tue, 05 Dec 2023 02:36:09 -0800 (PST) Received: from localhost ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id s22-20020a2e98d6000000b002c9b899c449sm809872ljj.59.2023.12.05.02.36.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 02:36:08 -0800 (PST) From: Serge Semin To: Andrew Lunn , Heiner Kallweit , Russell King , Alexandre Torgue , Jose Abreu , Jose Abreu , Maxime Chevallier , Tomer Maimon , Rob Herring , Krzysztof Kozlowski , Conor Dooley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Serge Semin , openbmc@lists.ozlabs.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 04/16] net: pcs: xpcs: Explicitly return error on caps validation Date: Tue, 5 Dec 2023 13:35:25 +0300 Message-ID: <20231205103559.9605-5-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20231205103559.9605-1-fancer.lancer@gmail.com> References: <20231205103559.9605-1-fancer.lancer@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Tue, 05 Dec 2023 02:36:47 -0800 (PST) If an unsupported interface is requested to be validated then there is no need in further capabilities and-ing since the local array will be left initialized with zeros. Let's explicitly return EINVAL error in that case in order to inform the caller about invalid link-state interface. In any case the phylink_validate_mac_and_pcs() would terminate with error further link-state validation so the suggested update won't change the validation procedure semantics. Signed-off-by: Serge Semin --- drivers/net/pcs/pcs-xpcs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 92c47da61db4..46afeb5510c0 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -613,14 +613,15 @@ static int xpcs_validate(struct phylink_pcs *pcs, unsigned long *supported, xpcs = phylink_pcs_to_xpcs(pcs); compat = xpcs_find_compat(xpcs->id, state->interface); + if (!compat) + return -EINVAL; /* Populate the supported link modes for this PHY interface type. * FIXME: what about the port modes and autoneg bit? This masks * all those away. */ - if (compat) - for (i = 0; compat->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) - set_bit(compat->supported[i], xpcs_supported); + for (i = 0; compat->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) + set_bit(compat->supported[i], xpcs_supported); linkmode_and(supported, supported, xpcs_supported); -- 2.42.1