Skip to content

Commit 640e37f

Browse files
Allison Hendersongregkh
authored andcommitted
net/rds: reset op_nents when zerocopy page pin fails
commit e174929 upstream. When iov_iter_get_pages2() fails in rds_message_zcopy_from_user(), the pinned pages are released with put_page(), and rm->data.op_mmp_znotifier is cleared. But we fail to properly clear rm->data.op_nents. Later when rds_message_purge() is called from rds_sendmsg() the cleanup loop iterates over the incorrectly non zero number of op_nents and frees them again. Fix this by properly resetting op_nents when it should be in rds_message_zcopy_from_user(). Fixes: 0cebacc ("rds: zerocopy Tx support.") Signed-off-by: Allison Henderson <achender@kernel.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20260505234336.2132721-1-achender@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6bf4253 commit 640e37f

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

net/rds/message.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ static int rds_message_zcopy_from_user(struct rds_message *rm, struct iov_iter *
408408

409409
for (i = 0; i < rm->data.op_nents; i++)
410410
put_page(sg_page(&rm->data.op_sg[i]));
411+
rm->data.op_nents = 0;
411412
mmp = &rm->data.op_mmp_znotifier->z_mmp;
412413
mm_unaccount_pinned_pages(mmp);
413414
ret = -EFAULT;

0 commit comments

Comments
 (0)