diff options
author | Jeff Layton <jlayton@kernel.org> | 2023-03-27 13:21:37 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-04-13 17:55:21 +0300 |
commit | b623a8e5d38a69a3ef8644acb1030dd7c7bc28b3 (patch) | |
tree | c6766832e03af91b0b9edb34d257e3e5989be7f2 /fs/nfsd/blocklayout.c | |
parent | ffcbcf087581ae68ddc0a21460f7ecd4315bdd0e (diff) | |
download | linux-b623a8e5d38a69a3ef8644acb1030dd7c7bc28b3.tar.xz |
nfsd: call op_release, even when op_func returns an error
[ Upstream commit 15a8b55dbb1ba154d82627547c5761cac884d810 ]
For ops with "trivial" replies, nfsd4_encode_operation will shortcut
most of the encoding work and skip to just marshalling up the status.
One of the things it skips is calling op_release. This could cause a
memory leak in the layoutget codepath if there is an error at an
inopportune time.
Have the compound processing engine always call op_release, even when
op_func sets an error in op->status. With this change, we also need
nfsd4_block_get_device_info_scsi to set the gd_device pointer to NULL
on error to avoid a double free.
Reported-by: Zhi Li <yieli@redhat.com>
Link: https://bugzilla.redhat.com/show_bug.cgi?id=2181403
Fixes: 34b1744c91cc ("nfsd4: define ->op_release for compound ops")
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/nfsd/blocklayout.c')
-rw-r--r-- | fs/nfsd/blocklayout.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c index b6d01d51a746..e7e6e78d965d 100644 --- a/fs/nfsd/blocklayout.c +++ b/fs/nfsd/blocklayout.c @@ -296,6 +296,7 @@ nfsd4_block_get_device_info_scsi(struct super_block *sb, out_free_dev: kfree(dev); + gdp->gd_device = NULL; return ret; } |