On Wed, 13 Feb 2013 13:29:45 -0700
Tim Gardner <[email protected]> wrote:

> smatch analysis indicates a number of redundant NULL checks before
> calling kfree(), e.g.,
> 
> fs/ocfs2/alloc.c:6138 ocfs2_begin_truncate_log_recovery() info:
>  redundant null check on *tl_copy calling kfree()
> 
> fs/ocfs2/alloc.c:6755 ocfs2_zero_range_for_truncate() info:
>  redundant null check on pages calling kfree()
> 
> ...
>
> diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
> index 31b9463..83a1a1d 100644
> --- a/fs/ocfs2/alloc.c
> +++ b/fs/ocfs2/alloc.c
> @@ -6134,7 +6134,7 @@ bail:
>               iput(tl_inode);
>       brelse(tl_bh);
>  
> -     if (status < 0 && (*tl_copy)) {
> +     if (status < 0) {
>               kfree(*tl_copy);
>               *tl_copy = NULL;
>               mlog_errno(status);

This change does other things.  For example, if
ocfs2_begin_truncate_log_recovery()'s first "goto bail" is taken, we
will now call mlog_errno(status) twice.

That function is pretty confused about its error recovery and logging.
it needs some maintenance.  I'll omit this hunk of your patch.


> @@ -534,7 +533,7 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super 
> *osb,
>               mlog_errno(status);
>  
>  bail:
> -     if ((status < 0) && (*alloc_copy)) {
> +     if (status < 0) {
>               kfree(*alloc_copy);
>               *alloc_copy = NULL;
>       }

Similar, but this change lokos OK.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to