ocfs2: remove kfree() redundant null checks
authorTim Gardner <tim.gardner@canonical.com>
Fri, 22 Feb 2013 00:42:44 +0000 (16:42 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 22 Feb 2013 01:22:19 +0000 (17:22 -0800)
smatch analysis indicates a number of redundant NULL checks before
calling kfree(), eg:

  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()

etc....

[akpm@linux-foundation.org: revert dubious change in ocfs2_begin_truncate_log_recovery()]
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Acked-by: Joel Becker <jlbec@evilplan.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/ocfs2/alloc.c
fs/ocfs2/cluster/heartbeat.c
fs/ocfs2/cluster/tcp.c
fs/ocfs2/dlm/dlmdomain.c
fs/ocfs2/extent_map.c
fs/ocfs2/journal.c
fs/ocfs2/localalloc.c
fs/ocfs2/stack_o2cb.c
fs/ocfs2/super.c
fs/ocfs2/sysfile.c

index 31b9463fba1fb19259da764d94372ffffc0f6008..b8a9d87231b1badec1fb31f27c84265ca708aa55 100644 (file)
@@ -6751,8 +6751,7 @@ int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle,
                mlog_errno(ret);
 
 out:
-       if (pages)
-               kfree(pages);
+       kfree(pages);
 
        return ret;
 }
index f7c648d7d6bf1b0ecbc88cb6edaf79553eade538..42252bf64b5127f39eecb25a7aecd6f1cd57e511 100644 (file)
@@ -1471,8 +1471,7 @@ static void o2hb_region_release(struct config_item *item)
 
        mlog(ML_HEARTBEAT, "hb region release (%s)\n", reg->hr_dev_name);
 
-       if (reg->hr_tmp_block)
-               kfree(reg->hr_tmp_block);
+       kfree(reg->hr_tmp_block);
 
        if (reg->hr_slot_data) {
                for (i = 0; i < reg->hr_num_pages; i++) {
@@ -1486,8 +1485,7 @@ static void o2hb_region_release(struct config_item *item)
        if (reg->hr_bdev)
                blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE);
 
-       if (reg->hr_slots)
-               kfree(reg->hr_slots);
+       kfree(reg->hr_slots);
 
        kfree(reg->hr_db_regnum);
        kfree(reg->hr_db_livenodes);
index 1bfe8802cc1e231a95b4bca57414d7ef3ed40798..f0edbd84f7bce055a2e8d87fafafa5134468eaad 100644 (file)
@@ -1165,10 +1165,8 @@ out:
        o2net_debug_del_nst(&nst); /* must be before dropping sc and node */
        if (sc)
                sc_put(sc);
-       if (vec)
-               kfree(vec);
-       if (msg)
-               kfree(msg);
+       kfree(vec);
+       kfree(msg);
        o2net_complete_nsw(nn, &nsw, 0, 0, 0);
        return ret;
 }
index 9e89d70df337fc98836e87f90e38887a716843e6..dbb17c07656ae3ca88c75f02bb4d75100190ffea 100644 (file)
@@ -319,9 +319,7 @@ static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm)
        if (dlm->master_hash)
                dlm_free_pagevec((void **)dlm->master_hash, DLM_HASH_PAGES);
 
-       if (dlm->name)
-               kfree(dlm->name);
-
+       kfree(dlm->name);
        kfree(dlm);
 }
 
index f487aa3434428d889fdcc3e7c8df0a54879c6b8b..1c39efb71bab6d2c4926962c0a642d291e2b360b 100644 (file)
@@ -282,8 +282,7 @@ search:
        spin_unlock(&oi->ip_lock);
 
 out:
-       if (new_emi)
-               kfree(new_emi);
+       kfree(new_emi);
 }
 
 static int ocfs2_last_eb_is_empty(struct inode *inode,
index 2dd36af79e262f8de2051525e1baf8585786cba8..8eccfabcd12ed7a4b229499445585e662a977479 100644 (file)
@@ -1234,11 +1234,8 @@ static void ocfs2_queue_recovery_completion(struct ocfs2_journal *journal,
                /* Though we wish to avoid it, we are in fact safe in
                 * skipping local alloc cleanup as fsck.ocfs2 is more
                 * than capable of reclaiming unused space. */
-               if (la_dinode)
-                       kfree(la_dinode);
-
-               if (tl_dinode)
-                       kfree(tl_dinode);
+               kfree(la_dinode);
+               kfree(tl_dinode);
 
                if (qrec)
                        ocfs2_free_quota_recovery(qrec);
@@ -1408,8 +1405,7 @@ bail:
 
        mutex_unlock(&osb->recovery_lock);
 
-       if (rm_quota)
-               kfree(rm_quota);
+       kfree(rm_quota);
 
        /* no one is callint kthread_stop() for us so the kthread() api
         * requires that we call do_exit().  And it isn't exported, but
index a9f78c74d687ed5845587ac619081653f7e510b7..aebeacd807c3b9505c5e9bb859008469985588e2 100644 (file)
@@ -476,8 +476,7 @@ out:
        if (local_alloc_inode)
                iput(local_alloc_inode);
 
-       if (alloc_copy)
-               kfree(alloc_copy);
+       kfree(alloc_copy);
 }
 
 /*
@@ -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;
        }
@@ -1290,8 +1289,7 @@ bail:
        if (main_bm_inode)
                iput(main_bm_inode);
 
-       if (alloc_copy)
-               kfree(alloc_copy);
+       kfree(alloc_copy);
 
        if (ac)
                ocfs2_free_alloc_context(ac);
index 94368017edb378ce1e3961d1976408c954677c9a..bf1f8930456f145343089206ff3ec2469a532ad7 100644 (file)
@@ -376,7 +376,7 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn)
        dlm_register_eviction_cb(dlm, &priv->op_eviction_cb);
 
 out_free:
-       if (rc && conn->cc_private)
+       if (rc)
                kfree(conn->cc_private);
 
 out:
index 0e91ec22a940ea1488bab00191b8f54356578bd5..9b6910dec4ba79623027455e9833f4892ce3e0ea 100644 (file)
@@ -2525,8 +2525,7 @@ static int ocfs2_check_volume(struct ocfs2_super *osb)
                mlog_errno(status);
 
 finally:
-       if (local_alloc)
-               kfree(local_alloc);
+       kfree(local_alloc);
 
        if (status)
                mlog_errno(status);
@@ -2553,8 +2552,7 @@ static void ocfs2_delete_osb(struct ocfs2_super *osb)
         * we free it here.
         */
        kfree(osb->journal);
-       if (osb->local_alloc_copy)
-               kfree(osb->local_alloc_copy);
+       kfree(osb->local_alloc_copy);
        kfree(osb->uuid_str);
        ocfs2_put_dlm_debug(osb->osb_dlm_debug);
        memset(osb, 0, sizeof(struct ocfs2_super));
index 3d635f4bbb201dba77cc79bd57feb67862744d4b..f053688d22a349ebf6803ecd676f64566fe90de0 100644 (file)
@@ -91,8 +91,7 @@ static struct inode **get_local_system_inode(struct ocfs2_super *osb,
                } else
                        osb->local_system_inodes = local_system_inodes;
                spin_unlock(&osb->osb_lock);
-               if (unlikely(free))
-                       kfree(free);
+               kfree(free);
        }
 
        index = (slot * NUM_LOCAL_SYSTEM_INODES) +