public inbox for linux-usb@vger.kernel.org
 help / color / mirror / Atom feed
From: Florian Faber <faber@faberman.de>
To: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org
Subject: [PATCH] usb: gadget: f_mass_storage: Shut down mass storage device when USB connection is shut, down.
Date: Sat, 4 Sep 2021 17:32:58 +0200	[thread overview]
Message-ID: <5f9fbabd-2e2c-9389-446d-3bd1dd954a82@faberman.de> (raw)

f_mass_storage continues to send out packets after the connection to the 
USB host has been terminated, ignoring the error status.

Signed-off-by: Florian Faber <faber@faberman.de>

---
  drivers/usb/gadget/function/f_mass_storage.c | 4 ++++
  1 file changed, 4 insertions(+)

diff --git a/drivers/usb/gadget/function/f_mass_storage.c 
b/drivers/usb/gadget/function/f_mass_storage.c
index 6ad669dde41c..1e73ba629e43 100644
--- a/drivers/usb/gadget/function/f_mass_storage.c
+++ b/drivers/usb/gadget/function/f_mass_storage.c
@@ -529,6 +529,10 @@ static int start_transfer(struct fsg_dev *fsg, 
struct usb_ep *ep,
  		/* We can't do much more than wait for a reset */
  		req->status = rc;

+		if (rc==-ESHUTDOWN) {
+			fsg->common->running = 0;
+		}
+
  		/*
  		 * Note: currently the net2280 driver fails zero-length
  		 * submissions if DMA is enabled.
-- 
2.33.0

Flo
-- 
Machines can do the work, so people have time to think.

             reply	other threads:[~2021-09-04 15:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-04 15:32 Florian Faber [this message]
2021-09-04 16:09 ` [PATCH] usb: gadget: f_mass_storage: Shut down mass storage device when USB connection is shut, down Alan Stern
2021-09-04 16:17   ` Florian Faber
2021-09-04 16:25     ` Alan Stern

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=5f9fbabd-2e2c-9389-446d-3bd1dd954a82@faberman.de \
    --to=faber@faberman.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-usb@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