Article View: linux.kernel.netdev
Article #23326Re: [PATCH net-next] net: dsa: motorcomm: Unregister the MDIO buses on teardown
From: netdev-bot+sashiko
Date: Fri, 27 Nov 2026 04:14
Date: Fri, 27 Nov 2026 04:14
94 lines
10920 bytes
10920 bytes
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The patch switches the yt921x internal and external MDIO buses from devm-managed allocation and registration to manual… -- net: dsa: motorcomm: Unregister the MDIO buses on teardown The yt921x internal and external MDIO buses used devm-managed allocation and registration. This patch replaces that with mdiobus_alloc() plus of_mdiobus_register(), and frees the buses in .teardown() and on the yt921x_dsa_setup() error paths. A second .setup() within one registration should then no longer collide with a bus that is still registered. > diff --git a/drivers/net/dsa/motorcomm/chip.c b/drivers/net/dsa/motorcomm/chip.c > index a21d4bb5e1412..789a08dbe3b93 100644 > --- a/drivers/net/dsa/motorcomm/chip.c > +++ b/drivers/net/dsa/motorcomm/chip.c [ ... ] > @@ -2586,7 +2590,7 @@ static int yt921x_dsa_setup(struct dsa_switch *ds) > mutex_unlock(&priv->reg_lock); > > if (res) > - return res; > + goto err; > > res = yt921x_devlink_setup(priv); > if (res) [Severity: High] Should the yt921x_devlink_setup() failure also go to err? After this patch it still reads: res = yt921x_devlink_setup(priv); if (res) return res; If that fails, priv->mbus_int and priv->mbus_ext stay registered and allocated. The DSA core does not call ops->teardown() when ops->setup() fails. dsa_switch_setup() in net/dsa/dsa.c does: err = ds->ops->setup(ds); if (err < 0) goto unregister_notifier; That jump skips the teardown label. ds->setup also stays false, so dsa_switch_teardown() returns early. On this path yt921x_dsa_teardown() never runs. Before this patch, devm_of_mdiobus_register() cleaned up in this case. Now nothing unregisters or frees the buses, and mbus->priv still points at the devm-allocated priv from yt921x_mdio_probe(). priv is freed when the probe fails, or in a multi-chip tree when the switch is later unbound. After that, any access through the leaked bus reaches yt921x_mbus_int_read() or yt921x_mbus_int_write(), which call mutex_lock(&priv->reg_lock) on freed memory. If the module has been unloaded, the callbacks point into freed module text instead. The leaked bus also keeps its id (dev_name(dev)) under the same parent. Could a later setup or re-probe then hit the same __mdiobus_register() collision that this patch is meant to fix? Replacing the return res above with goto err would close this path. > @@ -2599,6 +2603,12 @@ static int yt921x_dsa_setup(struct dsa_switch *ds) > #endif > > return 0; > + > +err: > + yt921x_mbus_ext_remove(priv); > +err_mbus_int: > + yt921x_mbus_int_remove(priv); > + return res; > } -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261126034725.64709-1-mmyangfl%40gmail.com
Technical Details
Message-ID:
<179575287341.3135.2545531095986940323@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372447-linux-kernel-netdev=dewy.ruReferences:
<20261126034725.64709-1-mmyangfl@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372447-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net-next] net: dsa: motorcomm: Unregister the MDIO buses on teardown Date: Fri, 27 Nov 2026 04:14:33 +0000 Organization: Usenet Network Message-ID: <179575287341.3135.2545531095986940323@kernel.org> References: <20261126034725.64709-1-mmyangfl@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="634518"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:q8J9qLtnzR8MbvcYNBbuQBXJ8bM= sha256:JgAt+x7UooiiCVk+Cgpe42Pnyf4Di8Y1t/a7+QnKjk8= sha1:L8jFVrLPnz/IdxEw6FxnRLKMwgg= sha256:+bz0kfcXkM3/pmtIpi7n2aF/uESsLCK5gfj7U5xrmOc= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id DD5F0125F0E; Fri, 27 Nov 2026 07:14:55 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.401 X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QnKznQNeE9zf; Fri, 27 Nov 2026 07:14:48 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-372447-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 86224125F0C; Fri, 27 Nov 2026 07:14:38 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 740582F935; Fri, 27 Nov 2026 04:14:36 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795752876; b=JtR0KyA0s/OF6CfdLXW5aI+a4iaBs6YDCJP04Yw+OCaNBJ2BpcaMWWs12GMOO4hc0bDE vycuXAwObQ6NSpwJzfpAB1uqZMS5KPO25lMK9++fRBizFYoW4xTvb7sT6tg+jXaIzfwd2 8fc9doo7AKQobqSckWYO+rg40/paBQhjUz+xnqdyicDU0ov/CIKM8JAWI50ppH+XmA09j Fg+KeuLDOfIO0uhn/J4OYna+8ey0MPO2vZdYp+fyRcs1dYiSHGlvTxgin0xIQaRMiM4R3 MPaPY2XOItAun9Zvh5hGLL07RKYhTY4ER37BmCNSfw0ZtJCRX9JEka2/olKkfXf13qw== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795752876; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=SUrhKrfheYupw2Xo6QeTne49mSo55IfCxWZiIwl5hmQ=; b=N2ChYH0PXFwYsVvxcbjjWdiqgNhYWuoSd5O4Y8rNtiCjV69UZABwT0kkQSA319kKtVAv /dtTrrB6g86mO8N6j9kUXaUwKKLxjeHa8TfNxHKLRnk8uL5VAzFnK5VbK6b8Wk7ktbeQx Kpys5eLAPnx3sqP7FYEvzjLMluldKkrkEc1NmKIR+rrtAnTSTJ6pq3kDmKvNM0C9LXGCQ D6m/cy/NOHT30EZnmO7y7uqcDiiNdbCuy6loEVh9cSQgUKJ8DMKlFInMY6j0Yc9wZmGgl C047oE3/XD8ubc3XwO7vyxZCQwHVnsk4fZ+hLydfhyh8uulLvKrz7SQVrQHWlcKBwog== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=P0efXyaX; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1585E606A327; Fri, 27 Nov 2026 04:14:36 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=P0efXyaX X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795752875; b=wP/ci/wPBZj4JpcaMqpKmmca+lfIgamUoHaaJKamAWatwrMJ2pl3557xl77VyfhixuYI 47SFBbQJY4r/UsEXL6TKciYn09EEDC4nvwC9hYE39Vi1HWjBo2tYe5cmP5A/DcH9/AcNC IqLrlivbXnMcdpAocOfbaEqvg83AHhGAup5uIW1JJipCCbnPHCiCJcZm2W6Exa5YoCxWX ojqaGaZmcHMaE0w/kdvtEEGuEl0ZdOc8r4vTmTtB3V0lGSZCxP1BCwPGyAkS20q3TOtgB nCFBjCb92CWJjOPq6raleuNPXR4tIzFX6AAmsOvpqGg1lnzg1ZIrSb2IW7mpoRH9j8w== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795752875; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=SUrhKrfheYupw2Xo6QeTne49mSo55IfCxWZiIwl5hmQ=; b=cYLaxiLyga84jVYGudKu2Sbs+jAcJ53dtjDiDNzPlPEB+f/xwlicXwaMHGXEO03egw/8 AzZc/+gRoNByaB5RA6UqMtrpu859oGLSVip8BbYa7dWWiBbZg1TmsSaKY5ben/2ak/kR6 n8+Qjv4/3T8VwclU1cNmqifeL3K9Qvs432WeTOKVL79IwXQaf9Rm34MqIr6GW3j7VPiN1 E7qnWfkRsm0MlFAZJejZS6rr3U4gyZEIDVRngVyPPsR20Go/bvIKM0Ukr61Kr8D5h2tRN qOTzeWje/L/PsY40FGhiSbW/wPlHRRruA2gkjUmdORNob4KkDm1LTnLkWf8QzUjbckA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=P0efXyaX; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 336B5606A31C for <netdev@vger.kernel.org>; Fri, 27 Nov 2026 04:14:34 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE55C1F00898; Fri, 27 Nov 2026 04:14:33 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795752874; bh=SUrhKrfheYupw2Xo6QeTne49mSo55IfCxWZiIwl5hmQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=P0efXyaXNaTcKqlqJ5STALJ3x6D7caBJhutawlgfq2FPZkkh0bssyVbNxj5H27QOj DVeXrVlfIHRkdYk2amKsDJRW4OMbw9RkhKHkKJcS3LOdb6Ndn8O4joM/mZPriCjORs Fdc9F1QJH1rs4Gz2/l9ebhWk0qvoWEzYwiUpRp4qclkcTFKR/Vn6LYpT/q2ycL8g7U T6ruNd9YYgeokMiNKrUjjm9ib2JZI3RxuKNm+Ytz7LGbv0TjlY1tFyEUwTW4m99WnQ X4iGyeJ7c8ma1dL3YwFWmiJu5qxkWMTkNK9Wlo9f9aKqZo7jI4fCm3Drtw14OubekU gjjE+qw48F87g== X-Cc: netdev@vger.kernel.org, andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, linux@armlinux.org.uk X-In-Reply-To: <20261126034725.64709-1-mmyangfl@gmail.com> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list