diff mbox series

xfile: fix missing error unlock in xfile_fcb_find

Message ID 20240618005703.GD103034@frogsfrogsfrogs (mailing list archive)
State Superseded, archived
Headers show
Series xfile: fix missing error unlock in xfile_fcb_find | expand

Commit Message

Darrick J. Wong June 18, 2024, 12:57 a.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

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

Coverity-id: 1604113
Coverity-id: 1604099
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 libxfs/xfile.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Carlos Maiolino June 18, 2024, 11:27 a.m. UTC | #1
On Mon, Jun 17, 2024 at 05:57:03PM GMT, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Fix a missing mutex pthread_mutex_unlock and uninitialized return value
> in xfile_fcb_find.
> 
> Coverity-id: 1604113
> Coverity-id: 1604099
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>


> ---
>  libxfs/xfile.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libxfs/xfile.c b/libxfs/xfile.c
> index fdb76f406647..6e0fa809a296 100644
> --- a/libxfs/xfile.c
> +++ b/libxfs/xfile.c
> @@ -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);
Christoph Hellwig June 19, 2024, 6:21 a.m. UTC | #2
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/libxfs/xfile.c b/libxfs/xfile.c
index fdb76f406647..6e0fa809a296 100644
--- a/libxfs/xfile.c
+++ b/libxfs/xfile.c
@@ -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);