diff mbox series

xfs: Initialize error in xfs_attr_remove_iter

Message ID 20210622210852.9511-1-allison.henderson@oracle.com (mailing list archive)
State Accepted
Headers show
Series xfs: Initialize error in xfs_attr_remove_iter | expand

Commit Message

Allison Henderson June 22, 2021, 9:08 p.m. UTC
A recent bug report generated a warning that a code path in
xfs_attr_remove_iter could potentially return error uninitialized in the
case of XFS_DAS_RM_SHRINK state.  Fix this by initializing error.

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/xfs/libxfs/xfs_attr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Brian Foster June 23, 2021, 10:18 a.m. UTC | #1
On Tue, Jun 22, 2021 at 02:08:52PM -0700, Allison Henderson wrote:
> A recent bug report generated a warning that a code path in
> xfs_attr_remove_iter could potentially return error uninitialized in the
> case of XFS_DAS_RM_SHRINK state.  Fix this by initializing error.
> 
> Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---

Reviewed-by: Brian Foster <bfoster@redhat.com>

>  fs/xfs/libxfs/xfs_attr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index 611dc67..d9d7d51 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -1375,7 +1375,7 @@ xfs_attr_remove_iter(
>  {
>  	struct xfs_da_args		*args = dac->da_args;
>  	struct xfs_da_state		*state = dac->da_state;
> -	int				retval, error;
> +	int				retval, error = 0;
>  	struct xfs_inode		*dp = args->dp;
>  
>  	trace_xfs_attr_node_removename(args);
> -- 
> 2.7.4
>
Bill O'Donnell June 23, 2021, 8 p.m. UTC | #2
On Tue, Jun 22, 2021 at 02:08:52PM -0700, Allison Henderson wrote:
> A recent bug report generated a warning that a code path in
> xfs_attr_remove_iter could potentially return error uninitialized in the
> case of XFS_DAS_RM_SHRINK state.  Fix this by initializing error.
> 
> Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>

> ---
>  fs/xfs/libxfs/xfs_attr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index 611dc67..d9d7d51 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -1375,7 +1375,7 @@ xfs_attr_remove_iter(
>  {
>  	struct xfs_da_args		*args = dac->da_args;
>  	struct xfs_da_state		*state = dac->da_state;
> -	int				retval, error;
> +	int				retval, error = 0;
>  	struct xfs_inode		*dp = args->dp;
>  
>  	trace_xfs_attr_node_removename(args);
> -- 
> 2.7.4
>
Darrick J. Wong June 25, 2021, 6:20 p.m. UTC | #3
On Tue, Jun 22, 2021 at 02:08:52PM -0700, Allison Henderson wrote:
> A recent bug report generated a warning that a code path in
> xfs_attr_remove_iter could potentially return error uninitialized in the
> case of XFS_DAS_RM_SHRINK state.  Fix this by initializing error.
> 
> Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

Looks good,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  fs/xfs/libxfs/xfs_attr.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
> index 611dc67..d9d7d51 100644
> --- a/fs/xfs/libxfs/xfs_attr.c
> +++ b/fs/xfs/libxfs/xfs_attr.c
> @@ -1375,7 +1375,7 @@ xfs_attr_remove_iter(
>  {
>  	struct xfs_da_args		*args = dac->da_args;
>  	struct xfs_da_state		*state = dac->da_state;
> -	int				retval, error;
> +	int				retval, error = 0;
>  	struct xfs_inode		*dp = args->dp;
>  
>  	trace_xfs_attr_node_removename(args);
> -- 
> 2.7.4
>
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_attr.c b/fs/xfs/libxfs/xfs_attr.c
index 611dc67..d9d7d51 100644
--- a/fs/xfs/libxfs/xfs_attr.c
+++ b/fs/xfs/libxfs/xfs_attr.c
@@ -1375,7 +1375,7 @@  xfs_attr_remove_iter(
 {
 	struct xfs_da_args		*args = dac->da_args;
 	struct xfs_da_state		*state = dac->da_state;
-	int				retval, error;
+	int				retval, error = 0;
 	struct xfs_inode		*dp = args->dp;
 
 	trace_xfs_attr_node_removename(args);