Skip to content

Commit 43439d8

Browse files
committed
NFSv4.2: Fix a potential double free with READ_PLUS
kfree()-ing the scratch page isn't enough, we also need to set the pointer back to NULL to avoid a double-free in the case of a resend. Fixes: fbd2a05 (NFSv4.2: Rework scratch handling for READ_PLUS) Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent d180891 commit 43439d8

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

fs/nfs/nfs4proc.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5437,10 +5437,18 @@ static bool nfs4_read_plus_not_supported(struct rpc_task *task,
54375437
return false;
54385438
}
54395439

5440-
static int nfs4_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr)
5440+
static inline void nfs4_read_plus_scratch_free(struct nfs_pgio_header *hdr)
54415441
{
5442-
if (hdr->res.scratch)
5442+
if (hdr->res.scratch) {
54435443
kfree(hdr->res.scratch);
5444+
hdr->res.scratch = NULL;
5445+
}
5446+
}
5447+
5448+
static int nfs4_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr)
5449+
{
5450+
nfs4_read_plus_scratch_free(hdr);
5451+
54445452
if (!nfs4_sequence_done(task, &hdr->res.seq_res))
54455453
return -EAGAIN;
54465454
if (nfs4_read_stateid_changed(task, &hdr->args))

0 commit comments

Comments
 (0)