Files
linux/fs
Shardul Bankar df8d829bba nfsd: fix memory leak in nfsd_create_serv error paths
When nfsd_create_serv() calls percpu_ref_init() to initialize
nn->nfsd_net_ref, it allocates both a percpu reference counter
and a percpu_ref_data structure (64 bytes). However, if the
function fails later due to svc_create_pooled() returning NULL
or svc_bind() returning an error, these allocations are not
cleaned up, resulting in a memory leak.

The leak manifests as:
- Unreferenced percpu allocation (8 bytes per CPU)
- Unreferenced percpu_ref_data structure (64 bytes)

Fix this by adding percpu_ref_exit() calls in both error paths
to properly clean up the percpu_ref_init() allocations.

This patch fixes the percpu_ref leak in nfsd_create_serv() seen
as an auxiliary leak in syzbot report 099461f8558eb0a1f4f3; the
prepare_creds() and vsock-related leaks in the same report
remain to be addressed separately.

Reported-by: syzbot+099461f8558eb0a1f4f3@syzkaller.appspotmail.com
Link: https://syzkaller.appspot.com/bug?extid=099461f8558eb0a1f4f3
Fixes: 47e988147f ("nfsd: add nfsd_serv_try_get and nfsd_serv_put")
Signed-off-by: Shardul Bankar <shardul.b@mpiricsoftware.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2025-12-18 11:18:39 -05:00
..
2025-06-10 22:21:16 -04:00
2025-09-13 17:32:47 -07:00
2025-09-13 16:55:07 -07:00
2025-09-13 16:55:13 -07:00
2025-09-16 23:59:38 -04:00
2025-09-21 19:24:50 -04:00
2025-09-26 10:21:23 +02:00
2025-10-07 12:48:33 +02:00
2025-09-01 13:08:01 +02:00
2025-09-29 13:43:52 -07:00
2025-08-29 15:08:07 +02:00
2025-05-23 14:20:44 +02:00