Skip to content

Commit 4659ed7

Browse files
Tom Rixamschuma-ntap
authored andcommitted
nfs: Fix memory leak of export_path
The try_location function is called within a loop by nfs_follow_referral. try_location calls nfs4_pathname_string to created the export_path. nfs4_pathname_string allocates the memory. export_path is stored in the nfs_fs_context/fs_context structure similarly as hostname and source. But whereas the ctx hostname and source are freed before assignment, export_path is not. So if there are multiple loops, the new export_path will overwrite the old without the old being freed. So call kfree for export_path. Signed-off-by: Tom Rix <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent b7ade38 commit 4659ed7

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/nfs/nfs4namespace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ static int try_location(struct fs_context *fc,
308308
if (IS_ERR(export_path))
309309
return PTR_ERR(export_path);
310310

311+
kfree(ctx->nfs_server.export_path);
311312
ctx->nfs_server.export_path = export_path;
312313

313314
source = kmalloc(len + 1 + ctx->nfs_server.export_path_len + 1,

0 commit comments

Comments
 (0)