Skip to contentSkip to conversation

xfile: fix missing error unlock in xfile_fcb_find

PATCH In review Darrick J. Wong 3 participants 3 messages Jun 18, 2024 – Jun 19, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfile: fix missing error unlock in xfile_fcb_find

From: Darrick J. Wong <[email protected]>

Fix a missing mutex pthread_mutex_unlock and uninitialized return value in xfile_fcb_find.

Coverity-id: 1604113
Coverity-id: 1604099

---
 libxfs/xfile.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
libxfs/xfile.c +3 -3
index fdb76f406647..6e0fa809a296 100644
@@ -179,7 +179,7 @@ xfile_fcb_find(
 {
 	struct xfile_fcb	*fcb;
 	int			ret;
-	int			error;
+	int			error = 0;
 
 	/* No maximum range means that the caller gets a private memfd. */
 	if (maxbytes == 0) {
@@ -222,13 +222,13 @@ xfile_fcb_find(
 	/* Otherwise, open a new memfd and add it to our list. */
 	error = xfile_fcb_create(description, &fcb);
 	if (error)
-		return error;
+		goto out_unlock;
 
 	ret = ftruncate(fcb->fd, maxbytes);
 	if (ret) {
 		error = -errno;
 		xfile_fcb_irele(fcb, 0, maxbytes);
-		return error;
+		goto out_unlock;
 	}
 
 	list_add_tail(&fcb->fcb_list, &fcb_list);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Fix a missing mutex pthread_mutex_unlock and uninitialized return value in xfile_fcb_find.

Coverity-id: 1604113
Coverity-id: 1604099

Quoted 33 lines
---
 libxfs/xfile.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
libxfs/xfile.c +3 -3
index fdb76f406647..6e0fa809a296 100644
@@ -179,7 +179,7 @@ xfile_fcb_find(
 {
 	struct xfile_fcb	*fcb;
 	int			ret;
-	int			error;
+	int			error = 0;
 
 	/* No maximum range means that the caller gets a private memfd. */
 	if (maxbytes == 0) {
@@ -222,13 +222,13 @@ xfile_fcb_find(
 	/* Otherwise, open a new memfd and add it to our list. */
 	error = xfile_fcb_create(description, &fcb);
 	if (error)
-		return error;
+		goto out_unlock;
 
 	ret = ftruncate(fcb->fd, maxbytes);
 	if (ret) {
 		error = -errno;
 		xfile_fcb_irele(fcb, 0, maxbytes);
-		return error;
+		goto out_unlock;
 	}
 
 	list_add_tail(&fcb->fcb_list, &fcb_list);