Re: [PATCH] usb: gadget: f_fs: fix use-after-free in ffs_func_unbind

From: Shuangpeng

Date: Fri Nov 20 2026 - 15:35:06 EST




> On Nov 20, 2026, at 05:21, Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, Aug 14, 2026 at 09:38:18PM -0400, Shuangpeng Bai wrote:
>
> Are you sure this is ok? This means you now have a double reference.

The get is paired with a put at the end of the function, but taking and
dropping an extra reference isn't the cleanest way to fix this. The real
problem is the ordering: ffs_func_unbind() keeps using ffs after
functionfs_unbind() drops the reference. I'll send a v2 that moves
functionfs_unbind() to the end of ffs_func_unbind() instead, so no extra
reference is needed.

Best,
Shuangpeng


>
> thanks,
>
> greg k-h