Skip to contentSkip to conversation

netfs: Fix wrong sort of request put in error handling

PATCH New David Howells 1 participant 1 message Apr 25

Subsystems (2)
lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

PATCH 1/1 netfs: Fix wrong sort of request put in error handling

Fix netfs_write_begin() to call netfs_put_request(), not netfs_put_failed_request(), if it has already tried to dispatch the request.

Fixes 453f1cc34a8f ("netfs: Fix leak of request in netfs_write_begin() error handling")
cc Paulo Alcantara <[email protected]>
---
 fs/netfs/buffered_read.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/netfs/buffered_read.c +2 -2
index 5c78ec14e46b..7e7dacded8f7 100644
@@ -693,9 +693,9 @@ int netfs_write_begin(struct netfs_inode *ctx,
 
 	netfs_read_to_pagecache(rreq, NULL);
 	ret = netfs_wait_for_read(rreq);
-	if (ret < 0)
-		goto error_put;
 	netfs_put_request(rreq, netfs_rreq_trace_put_return);
+	if (ret < 0)
+		goto error;
 
 have_folio:
 	ret = folio_wait_private_2_killable(folio);