提交 d787ab09 编写于 作者: T Tim Gardner 提交者: Linus Torvalds

ocfs2: remove kfree() redundant null checks

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: NTim Gardner <tim.gardner@canonical.com>
Cc: Mark Fasheh <mfasheh@suse.com>
Acked-by: NJoel Becker <jlbec@evilplan.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 49deb4bc
...@@ -6751,8 +6751,7 @@ int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle, ...@@ -6751,8 +6751,7 @@ int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle,
mlog_errno(ret); mlog_errno(ret);
out: out:
if (pages) kfree(pages);
kfree(pages);
return ret; return ret;
} }
......
...@@ -1471,8 +1471,7 @@ static void o2hb_region_release(struct config_item *item) ...@@ -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); 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) { if (reg->hr_slot_data) {
for (i = 0; i < reg->hr_num_pages; i++) { for (i = 0; i < reg->hr_num_pages; i++) {
...@@ -1486,8 +1485,7 @@ static void o2hb_region_release(struct config_item *item) ...@@ -1486,8 +1485,7 @@ static void o2hb_region_release(struct config_item *item)
if (reg->hr_bdev) if (reg->hr_bdev)
blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE); 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_regnum);
kfree(reg->hr_db_livenodes); kfree(reg->hr_db_livenodes);
......
...@@ -1165,10 +1165,8 @@ int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *caller_vec, ...@@ -1165,10 +1165,8 @@ int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *caller_vec,
o2net_debug_del_nst(&nst); /* must be before dropping sc and node */ o2net_debug_del_nst(&nst); /* must be before dropping sc and node */
if (sc) if (sc)
sc_put(sc); sc_put(sc);
if (vec) kfree(vec);
kfree(vec); kfree(msg);
if (msg)
kfree(msg);
o2net_complete_nsw(nn, &nsw, 0, 0, 0); o2net_complete_nsw(nn, &nsw, 0, 0, 0);
return ret; return ret;
} }
......
...@@ -319,9 +319,7 @@ static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm) ...@@ -319,9 +319,7 @@ static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm)
if (dlm->master_hash) if (dlm->master_hash)
dlm_free_pagevec((void **)dlm->master_hash, DLM_HASH_PAGES); dlm_free_pagevec((void **)dlm->master_hash, DLM_HASH_PAGES);
if (dlm->name) kfree(dlm->name);
kfree(dlm->name);
kfree(dlm); kfree(dlm);
} }
......
...@@ -282,8 +282,7 @@ void ocfs2_extent_map_insert_rec(struct inode *inode, ...@@ -282,8 +282,7 @@ void ocfs2_extent_map_insert_rec(struct inode *inode,
spin_unlock(&oi->ip_lock); spin_unlock(&oi->ip_lock);
out: out:
if (new_emi) kfree(new_emi);
kfree(new_emi);
} }
static int ocfs2_last_eb_is_empty(struct inode *inode, static int ocfs2_last_eb_is_empty(struct inode *inode,
......
...@@ -1234,11 +1234,8 @@ static void ocfs2_queue_recovery_completion(struct ocfs2_journal *journal, ...@@ -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 /* Though we wish to avoid it, we are in fact safe in
* skipping local alloc cleanup as fsck.ocfs2 is more * skipping local alloc cleanup as fsck.ocfs2 is more
* than capable of reclaiming unused space. */ * than capable of reclaiming unused space. */
if (la_dinode) kfree(la_dinode);
kfree(la_dinode); kfree(tl_dinode);
if (tl_dinode)
kfree(tl_dinode);
if (qrec) if (qrec)
ocfs2_free_quota_recovery(qrec); ocfs2_free_quota_recovery(qrec);
...@@ -1408,8 +1405,7 @@ static int __ocfs2_recovery_thread(void *arg) ...@@ -1408,8 +1405,7 @@ static int __ocfs2_recovery_thread(void *arg)
mutex_unlock(&osb->recovery_lock); 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 /* no one is callint kthread_stop() for us so the kthread() api
* requires that we call do_exit(). And it isn't exported, but * requires that we call do_exit(). And it isn't exported, but
......
...@@ -476,8 +476,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) ...@@ -476,8 +476,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb)
if (local_alloc_inode) if (local_alloc_inode)
iput(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, ...@@ -534,7 +533,7 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb,
mlog_errno(status); mlog_errno(status);
bail: bail:
if ((status < 0) && (*alloc_copy)) { if (status < 0) {
kfree(*alloc_copy); kfree(*alloc_copy);
*alloc_copy = NULL; *alloc_copy = NULL;
} }
...@@ -1290,8 +1289,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb, ...@@ -1290,8 +1289,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
if (main_bm_inode) if (main_bm_inode)
iput(main_bm_inode); iput(main_bm_inode);
if (alloc_copy) kfree(alloc_copy);
kfree(alloc_copy);
if (ac) if (ac)
ocfs2_free_alloc_context(ac); ocfs2_free_alloc_context(ac);
......
...@@ -376,7 +376,7 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn) ...@@ -376,7 +376,7 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn)
dlm_register_eviction_cb(dlm, &priv->op_eviction_cb); dlm_register_eviction_cb(dlm, &priv->op_eviction_cb);
out_free: out_free:
if (rc && conn->cc_private) if (rc)
kfree(conn->cc_private); kfree(conn->cc_private);
out: out:
......
...@@ -2525,8 +2525,7 @@ static int ocfs2_check_volume(struct ocfs2_super *osb) ...@@ -2525,8 +2525,7 @@ static int ocfs2_check_volume(struct ocfs2_super *osb)
mlog_errno(status); mlog_errno(status);
finally: finally:
if (local_alloc) kfree(local_alloc);
kfree(local_alloc);
if (status) if (status)
mlog_errno(status); mlog_errno(status);
...@@ -2553,8 +2552,7 @@ static void ocfs2_delete_osb(struct ocfs2_super *osb) ...@@ -2553,8 +2552,7 @@ static void ocfs2_delete_osb(struct ocfs2_super *osb)
* we free it here. * we free it here.
*/ */
kfree(osb->journal); kfree(osb->journal);
if (osb->local_alloc_copy) kfree(osb->local_alloc_copy);
kfree(osb->local_alloc_copy);
kfree(osb->uuid_str); kfree(osb->uuid_str);
ocfs2_put_dlm_debug(osb->osb_dlm_debug); ocfs2_put_dlm_debug(osb->osb_dlm_debug);
memset(osb, 0, sizeof(struct ocfs2_super)); memset(osb, 0, sizeof(struct ocfs2_super));
......
...@@ -91,8 +91,7 @@ static struct inode **get_local_system_inode(struct ocfs2_super *osb, ...@@ -91,8 +91,7 @@ static struct inode **get_local_system_inode(struct ocfs2_super *osb,
} else } else
osb->local_system_inodes = local_system_inodes; osb->local_system_inodes = local_system_inodes;
spin_unlock(&osb->osb_lock); spin_unlock(&osb->osb_lock);
if (unlikely(free)) kfree(free);
kfree(free);
} }
index = (slot * NUM_LOCAL_SYSTEM_INODES) + index = (slot * NUM_LOCAL_SYSTEM_INODES) +
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册