All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpio: mpsse: return -ENODEV when the USB interface is gone
@ 2026-12-05 16:46 YuanZhe Liu
  2026-12-05 16:58 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: YuanZhe Liu @ 2026-12-05 16:46 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski
  Cc: Mary Strodl, linux-gpio, linux-kernel, stable, Bin Yu, Cheng Wen

gpio_mpsse_disconnect() clears priv->intf and the interface drvdata,
but the GPIO callbacks keep dereferencing priv->intf.  A line request
issued while the device is being unplugged reaches
gpio_mpsse_set_bank() after priv->intf has been cleared, and
mpsse_bulk_xfer() calls usb_get_intfdata(NULL), which faults on
&intf->dev.driver_data.

Return -ENODEV when the interface or its drvdata is gone, and check
the same before mpsse_read() dereferences the private data.  This
covers both the direction input and direction output paths.

Fixes: c46a74ff05c0 ("gpio: add support for FTDI's MPSSE as GPIO")
Cc: stable@vger.kernel.org
Co-developed-by: Bin Yu <byu@xidian.edu.cn>
Signed-off-by: Bin Yu <byu@xidian.edu.cn>
Co-developed-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: Cheng Wen <wencheng@xidian.edu.cn>
Signed-off-by: YuanZhe Liu <25031212351@stu.xidian.edu.cn>
---
 drivers/gpio/gpio-mpsse.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-mpsse.c b/drivers/gpio/gpio-mpsse.c
index 61c5ca96314b..ae1a97645214 100644
--- a/drivers/gpio/gpio-mpsse.c
+++ b/drivers/gpio/gpio-mpsse.c
@@ -105,11 +105,20 @@ static DEFINE_IDA(gpio_mpsse_ida);
 
 static int mpsse_bulk_xfer(struct usb_interface *intf, struct bulk_desc *desc)
 {
-	struct mpsse_priv *priv = usb_get_intfdata(intf);
-	struct usb_device *udev = priv->udev;
+	struct mpsse_priv *priv;
+	struct usb_device *udev;
 	unsigned int pipe;
 	int ret;
 
+	if (!intf)
+		return -ENODEV;
+
+	priv = usb_get_intfdata(intf);
+	if (!priv)
+		return -ENODEV;
+
+	udev = priv->udev;
+
 	if (desc->tx)
 		pipe = usb_sndbulkpipe(udev, priv->bulk_out->bEndpointAddress);
 	else
@@ -144,7 +153,14 @@ static int mpsse_read(struct usb_interface *intf, u8 *buf, size_t len)
 {
 	int ret;
 	struct bulk_desc desc;
-	struct mpsse_priv *priv = usb_get_intfdata(intf);
+	struct mpsse_priv *priv;
+
+	if (!intf)
+		return -ENODEV;
+
+	priv = usb_get_intfdata(intf);
+	if (!priv)
+		return -ENODEV;
 
 	desc.len_actual = 0;
 	desc.tx = false;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-05 16:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05 16:46 [PATCH] gpio: mpsse: return -ENODEV when the USB interface is gone YuanZhe Liu
2026-12-05 16:58 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.