From: Wentao Liang <vulab@iscas.ac.cn>
To: andrew@lunn.ch
Cc: davem@davemloft.net, edumazet@google.com, f.fainelli@gmail.com,
kuba@kernel.org, linusw@kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, olteanv@gmail.com, pabeni@redhat.com,
paweldembicki@gmail.com, Wentao Liang <vulab@iscas.ac.cn>,
stable@vger.kernel.org
Subject: [PATCH] net: dsa: vitesse-vsc73xx: Fix SPI device reference leak in vsc73xx_spi_probe()
Date: Thu, 17 Sep 2026 10:49:20 +0000 [thread overview]
Message-ID: <20260917104920.2147568-1-vulab@iscas.ac.cn> (raw)
spi_dev_get() takes a reference on the SPI device, but neither the
probe error paths nor vsc73xx_spi_remove() ever release it, so the
spi_device can never be freed after the driver has been unbound.
Release the reference on both probe error paths and in remove().
Fixes: 95711cd5f0b4 ("net: dsa: vsc73xx: Split vsc73xx driver")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
drivers/net/dsa/vitesse-vsc73xx-spi.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/net/dsa/vitesse-vsc73xx-spi.c b/drivers/net/dsa/vitesse-vsc73xx-spi.c
index 85b9a0f51dd8..7b784320c41e 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-spi.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-spi.c
@@ -153,10 +153,15 @@ static int vsc73xx_spi_probe(struct spi_device *spi)
ret = spi_setup(spi);
if (ret < 0) {
dev_err(dev, "spi setup failed.\n");
+ spi_dev_put(vsc_spi->spi);
return ret;
}
- return vsc73xx_probe(&vsc_spi->vsc);
+ ret = vsc73xx_probe(&vsc_spi->vsc);
+ if (ret)
+ spi_dev_put(vsc_spi->spi);
+
+ return ret;
}
static void vsc73xx_spi_remove(struct spi_device *spi)
@@ -167,6 +172,8 @@ static void vsc73xx_spi_remove(struct spi_device *spi)
return;
vsc73xx_remove(&vsc_spi->vsc);
+
+ spi_dev_put(vsc_spi->spi);
}
static void vsc73xx_spi_shutdown(struct spi_device *spi)
--
2.34.1
next reply other threads:[~2026-09-17 10:49 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 10:49 Wentao Liang [this message]
2026-09-17 12:40 ` [PATCH] net: dsa: vitesse-vsc73xx: Fix SPI device reference leak in vsc73xx_spi_probe() Andrew Lunn
2026-09-17 22:22 ` Linus Walleij
2026-09-18 1:53 ` Andrew Lunn
2026-09-18 8:39 ` Linus Walleij
2026-09-21 9:56 ` Simon Horman
2026-09-21 11:09 ` netdev-bot+sashiko
2026-09-23 1:20 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260917104920.2147568-1-vulab@iscas.ac.cn \
--to=vulab@iscas.ac.cn \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=f.fainelli@gmail.com \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=paweldembicki@gmail.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox