Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp797180rdb; Tue, 5 Dec 2023 23:17:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGr9+eI2vCJZ6Zbo31el5S/aTk0lkl/7TFPYi/X2wenBSeUgZWwp8IHxY9EfpL+/Y5tnlom X-Received: by 2002:a17:902:c40c:b0:1d1:ca00:d20b with SMTP id k12-20020a170902c40c00b001d1ca00d20bmr520135plk.46.1701847075364; Tue, 05 Dec 2023 23:17:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701847075; cv=none; d=google.com; s=arc-20160816; b=xHWffC0eW8GOH3swy+A+bNYOCpRB6iu3VhPsuh56BAiTQJNivzZ5FAEFq5Z5y1tk9w QUEf1zQGE2V0xWXkRySRUfdY4UO1CBO0n2Gfh1Rf5uy/gMgZ/DoF8PdMRiCC53tvjVaK BO7aM2MkvEcFJEv87Z5Ehamp3Em0J9Zb8OpQxMbSCXgfUeSRNyAIs+iH7PeBjaQIY2bB hQ0Ewn0PDC+khdcBBa3r54jDO3YFkk1DIU4AOk5qqlVkIPmFO0kDN8rLWblQ3KhVZODJ SAIPNUPXCX/rzhqzkrmp28h3aFF4X2DJK4juHdthPRt5qrGDIZwjCMJJT1m1dCW82wA7 kRyw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=+H62xYUVYv9m4br7cg0DgyNn6m4JbUs5+N/PVPX56JM=; fh=uKvpeuvk3JF9LfD67BE/M+DIhAvDvegRMd/dnAqLNyk=; b=oTlKBltvA4dj659ujbegYIH9vwGKf0RbGT/OS19SxzKaE3Ujg8A02zMvpFz1qQgp3B gGLnHFD5ZYIV3EhvBRwKPK1yLWoXL9QrrRGfXNG8w4KDv0kHN0P2hYcSOV0/UI6nTPyU ol6txe6rDX9ZHwoxpra/B80JiRMaIyua7aJuZ7IzN0GRthknvSel9AH/aUWHlOyWxtjk yfVnVKMRus6ISgmb2D5fqmR/lFyKsyPmR8DFb28BCdPNGOyeAo9y3NJFXf51xFmFxptp FXoI/Rd2HGkZZLVEgWvFEESCSxrG0dlKqRjvJcOh4VExlapFJvhvV6JjZp7YsJpSbh8O nTSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@geanix.com header.s=default2211 header.b="orh0/fxn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id b12-20020a170902a9cc00b001d000c817e2si7633549plr.398.2023.12.05.23.17.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 23:17:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@geanix.com header.s=default2211 header.b="orh0/fxn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id BFBE5803F7A6; Tue, 5 Dec 2023 23:17:52 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376962AbjLFHRh (ORCPT + 99 others); Wed, 6 Dec 2023 02:17:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1376923AbjLFHRg (ORCPT ); Wed, 6 Dec 2023 02:17:36 -0500 Received: from www530.your-server.de (www530.your-server.de [188.40.30.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC65F135; Tue, 5 Dec 2023 23:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=geanix.com; s=default2211; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=+H62xYUVYv9m4br7cg0DgyNn6m4JbUs5+N/PVPX56JM=; b=orh0/fxnE4NeMLDDyd/Te3IbWW 3OIDv19m9XNBLLmL0BneUzz1K1wcODjswD+O8g1TI5nfiL8G74Ecn0qqfJ1aAlb6CA9YsmdrocFF0 SV2GiVg/oC5O5vpiNs2ySi8VsBrEcyCPbQ3OO75FMiCtek4cCNvPyyg5wo0uGtER7HKLoH1BjRL/H v5zul/3wD5U4Umggmj+8L7EugVxamtCHJyUdpKWu+SVBzEZieqhRr24jcB0eVq/6rfmjvn/bWWgbN IOYobp8jH3LXpOmqZJaAisFBLHExOV8LLv8Vf7lWKW3nX0rYk1P14FuoiQWbCOLxMtNc6CjuIpXw6 LXdH5vGw==; Received: from sslproxy05.your-server.de ([78.46.172.2]) by www530.your-server.de with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rAmA7-0009kh-21; Wed, 06 Dec 2023 08:17:39 +0100 Received: from [185.17.218.86] (helo=zen..) by sslproxy05.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rAmA6-000Kzf-CG; Wed, 06 Dec 2023 08:17:38 +0100 From: Sean Nyekjaer To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Arun Ramadoss , Christian Eggers Cc: Sean Nyekjaer , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 net] net: dsa: microchip: provide a list of valid protocols for xmit handler Date: Wed, 6 Dec 2023 08:16:54 +0100 Message-ID: <20231206071655.1626479-1-sean@geanix.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Authenticated-Sender: sean@geanix.com X-Virus-Scanned: Clear (ClamAV 0.103.10/27114/Tue Dec 5 09:39:00 2023) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 05 Dec 2023 23:17:52 -0800 (PST) Provide a list of valid protocols for which the driver will provide it's deferred xmit handler. When using DSA_TAG_PROTO_KSZ8795 protocol, it does not provide a "connect" method, therefor ksz_connect() is not allocating ksz_tagger_data. This avoids the following null pointer dereference: ksz_connect_tag_protocol from dsa_register_switch+0x9ac/0xee0 dsa_register_switch from ksz_switch_register+0x65c/0x828 ksz_switch_register from ksz_spi_probe+0x11c/0x168 ksz_spi_probe from spi_probe+0x84/0xa8 spi_probe from really_probe+0xc8/0x2d8 Fixes: ab32f56a4100 ("net: dsa: microchip: ptp: add packet transmission timestamping") Signed-off-by: Sean Nyekjaer --- https://lore.kernel.org/netdev/20231205124636.1345761-1-sean@geanix.com/#R Changes since v1: - Provided a list of valid protocols drivers/net/dsa/microchip/ksz_common.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c index 42db7679c360..286e20f340e5 100644 --- a/drivers/net/dsa/microchip/ksz_common.c +++ b/drivers/net/dsa/microchip/ksz_common.c @@ -2624,10 +2624,18 @@ static int ksz_connect_tag_protocol(struct dsa_switch *ds, { struct ksz_tagger_data *tagger_data; - tagger_data = ksz_tagger_data(ds); - tagger_data->xmit_work_fn = ksz_port_deferred_xmit; - - return 0; + switch (proto) { + case DSA_TAG_PROTO_KSZ8795: + return 0; + case DSA_TAG_PROTO_KSZ9893: + case DSA_TAG_PROTO_KSZ9477: + case DSA_TAG_PROTO_LAN937X: + tagger_data = ksz_tagger_data(ds); + tagger_data->xmit_work_fn = ksz_port_deferred_xmit; + return 0; + default: + return -EPROTONOSUPPORT; + } } static int ksz_port_vlan_filtering(struct dsa_switch *ds, int port, -- 2.42.0