Re: [PATCH 3/3] usb: gadget: f_fs: Fix mmgrab()/mmdrop() balance.

From: Hongyu Xie

Date: Fri Oct 30 2026 - 04:21:03 EST


Hi Ingo,

I ran into the same imbalance while carrying a backport of 5eb5c72c72fe in
a 5.10-based product tree, and your analysis matches what I see.

mmgrab() is taken in both ffs_epfile_read_iter() and ffs_epfile_write_iter()
when the request is queued for AIO, but ffs_user_copy_worker() drops the
reference only inside

if (io_data->read && ret > 0)

so the reference is lost on every completed AIO write, and also on an AIO
read that completes with ret <= 0. Moving mmdrop() out of the block fixes
both cases, and it stays balanced with the mmgrab() in the iter functions.

The released stable trees carry the same code: 6.6.160, 6.12.111, 7.2.y and
rolling-lts (6.18.y) all still have mmdrop() inside the if. 5.10.y and
5.15.y are not affected, they still use the older kthread_use_mm() code
without mmgrab().

It would help to add

Fixes: 5eb5c72c72fe ("USB: gadget: ffs: fix mm lifetime handling")
Cc: stable@xxxxxxxxxxxxxxx

so the stable trees pick it up; the change itself applies there with only
offset differences.

Reviewed-by: Hongyu Xie <xiehongyu1@xxxxxxxxxx>

Thanks,
Hongyu