Linux USB
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: f_fs: Fix mmgrab()/mmdrop() balance.
@ 2026-11-09 10:37 Ingo Rohloff
  2026-11-09 10:41 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Ingo Rohloff @ 2026-11-09 10:37 UTC (permalink / raw)
  To: gregkh
  Cc: viro, nkapron, me, michael.bommarito, linux-usb, Ingo Rohloff,
	stable

This fixes commit 5eb5c72c72fe ("USB: gadget: ffs: fix mm lifetime
handling").  The problem is that the previous patch calls mmgrab() for
reads and writes, but it only calls mmdrop() for reads.  So with each
completed async IO write (via an USB IN endpoint) the number of mm_count
increases.

Signed-off-by: Ingo Rohloff <ingo.rohloff@lauterbach.com>
Link: https://lore.kernel.org/r/20260901120908.14386-4-ingo.rohloff@lauterbach.com
Fixes: 5eb5c72c72fe ("USB: gadget: ffs: fix mm lifetime handling")
Cc: stable@vger.kernel.org
---
- Originally posted as patch 3/3 of "usb: gadget: f_fs: cancellation and mm fixes"
  https://lore.kernel.org/r/20260901120908.14386-1-ingo.rohloff@lauterbach.com.
  Resend because rest of the series is still to be discussed.

 drivers/usb/gadget/function/f_fs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index c64a268e98a4..704cfae49f11 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -884,8 +884,8 @@ static void ffs_user_copy_worker(struct work_struct *work)
 		} else {
 			ret = -EFAULT;
 		}
-		mmdrop(io_data->mm);
 	}
+	mmdrop(io_data->mm);
 
 	io_data->kiocb->ki_complete(io_data->kiocb, ret);
 
-- 
2.55.0


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

end of thread, other threads:[~2026-11-09 10:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-09 10:37 [PATCH] usb: gadget: f_fs: Fix mmgrab()/mmdrop() balance Ingo Rohloff
2026-11-09 10:41 ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox