diff options
author | Tim Gardner <tim.gardner@canonical.com> | 2013-02-21 19:42:44 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-02-21 20:22:19 -0500 |
commit | d787ab0977c58e2c421b8d0ab49e363893ddb814 (patch) | |
tree | d55c305e7e011fcb271f8b8be4a7bc94274712a1 | |
parent | 49deb4bc227cb9db5b8ebf9434367f8bed057c7a (diff) |
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: 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>
-rw-r--r-- | fs/ocfs2/alloc.c | 3 | ||||
-rw-r--r-- | fs/ocfs2/cluster/heartbeat.c | 6 | ||||
-rw-r--r-- | fs/ocfs2/cluster/tcp.c | 6 | ||||
-rw-r--r-- | fs/ocfs2/dlm/dlmdomain.c | 4 | ||||
-rw-r--r-- | fs/ocfs2/extent_map.c | 3 | ||||
-rw-r--r-- | fs/ocfs2/journal.c | 10 | ||||
-rw-r--r-- | fs/ocfs2/localalloc.c | 8 | ||||
-rw-r--r-- | fs/ocfs2/stack_o2cb.c | 2 | ||||
-rw-r--r-- | fs/ocfs2/super.c | 6 | ||||
-rw-r--r-- | fs/ocfs2/sysfile.c | 3 |
10 files changed, 17 insertions, 34 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index 31b9463fba1f..b8a9d87231b1 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -6751,8 +6751,7 @@ int ocfs2_zero_range_for_truncate(struct inode *inode, handle_t *handle, | |||
6751 | mlog_errno(ret); | 6751 | mlog_errno(ret); |
6752 | 6752 | ||
6753 | out: | 6753 | out: |
6754 | if (pages) | 6754 | kfree(pages); |
6755 | kfree(pages); | ||
6756 | 6755 | ||
6757 | return ret; | 6756 | return ret; |
6758 | } | 6757 | } |
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c index f7c648d7d6bf..42252bf64b51 100644 --- a/fs/ocfs2/cluster/heartbeat.c +++ b/fs/ocfs2/cluster/heartbeat.c | |||
@@ -1471,8 +1471,7 @@ static void o2hb_region_release(struct config_item *item) | |||
1471 | 1471 | ||
1472 | mlog(ML_HEARTBEAT, "hb region release (%s)\n", reg->hr_dev_name); | 1472 | mlog(ML_HEARTBEAT, "hb region release (%s)\n", reg->hr_dev_name); |
1473 | 1473 | ||
1474 | if (reg->hr_tmp_block) | 1474 | kfree(reg->hr_tmp_block); |
1475 | kfree(reg->hr_tmp_block); | ||
1476 | 1475 | ||
1477 | if (reg->hr_slot_data) { | 1476 | if (reg->hr_slot_data) { |
1478 | for (i = 0; i < reg->hr_num_pages; i++) { | 1477 | for (i = 0; i < reg->hr_num_pages; i++) { |
@@ -1486,8 +1485,7 @@ static void o2hb_region_release(struct config_item *item) | |||
1486 | if (reg->hr_bdev) | 1485 | if (reg->hr_bdev) |
1487 | blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE); | 1486 | blkdev_put(reg->hr_bdev, FMODE_READ|FMODE_WRITE); |
1488 | 1487 | ||
1489 | if (reg->hr_slots) | 1488 | kfree(reg->hr_slots); |
1490 | kfree(reg->hr_slots); | ||
1491 | 1489 | ||
1492 | kfree(reg->hr_db_regnum); | 1490 | kfree(reg->hr_db_regnum); |
1493 | kfree(reg->hr_db_livenodes); | 1491 | kfree(reg->hr_db_livenodes); |
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index 1bfe8802cc1e..f0edbd84f7bc 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c | |||
@@ -1165,10 +1165,8 @@ out: | |||
1165 | o2net_debug_del_nst(&nst); /* must be before dropping sc and node */ | 1165 | o2net_debug_del_nst(&nst); /* must be before dropping sc and node */ |
1166 | if (sc) | 1166 | if (sc) |
1167 | sc_put(sc); | 1167 | sc_put(sc); |
1168 | if (vec) | 1168 | kfree(vec); |
1169 | kfree(vec); | 1169 | kfree(msg); |
1170 | if (msg) | ||
1171 | kfree(msg); | ||
1172 | o2net_complete_nsw(nn, &nsw, 0, 0, 0); | 1170 | o2net_complete_nsw(nn, &nsw, 0, 0, 0); |
1173 | return ret; | 1171 | return ret; |
1174 | } | 1172 | } |
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 9e89d70df337..dbb17c07656a 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c | |||
@@ -319,9 +319,7 @@ static void dlm_free_ctxt_mem(struct dlm_ctxt *dlm) | |||
319 | if (dlm->master_hash) | 319 | if (dlm->master_hash) |
320 | dlm_free_pagevec((void **)dlm->master_hash, DLM_HASH_PAGES); | 320 | dlm_free_pagevec((void **)dlm->master_hash, DLM_HASH_PAGES); |
321 | 321 | ||
322 | if (dlm->name) | 322 | kfree(dlm->name); |
323 | kfree(dlm->name); | ||
324 | |||
325 | kfree(dlm); | 323 | kfree(dlm); |
326 | } | 324 | } |
327 | 325 | ||
diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index f487aa343442..1c39efb71bab 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c | |||
@@ -282,8 +282,7 @@ search: | |||
282 | spin_unlock(&oi->ip_lock); | 282 | spin_unlock(&oi->ip_lock); |
283 | 283 | ||
284 | out: | 284 | out: |
285 | if (new_emi) | 285 | kfree(new_emi); |
286 | kfree(new_emi); | ||
287 | } | 286 | } |
288 | 287 | ||
289 | static int ocfs2_last_eb_is_empty(struct inode *inode, | 288 | static int ocfs2_last_eb_is_empty(struct inode *inode, |
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index 2dd36af79e26..8eccfabcd12e 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c | |||
@@ -1234,11 +1234,8 @@ static void ocfs2_queue_recovery_completion(struct ocfs2_journal *journal, | |||
1234 | /* Though we wish to avoid it, we are in fact safe in | 1234 | /* Though we wish to avoid it, we are in fact safe in |
1235 | * skipping local alloc cleanup as fsck.ocfs2 is more | 1235 | * skipping local alloc cleanup as fsck.ocfs2 is more |
1236 | * than capable of reclaiming unused space. */ | 1236 | * than capable of reclaiming unused space. */ |
1237 | if (la_dinode) | 1237 | kfree(la_dinode); |
1238 | kfree(la_dinode); | 1238 | kfree(tl_dinode); |
1239 | |||
1240 | if (tl_dinode) | ||
1241 | kfree(tl_dinode); | ||
1242 | 1239 | ||
1243 | if (qrec) | 1240 | if (qrec) |
1244 | ocfs2_free_quota_recovery(qrec); | 1241 | ocfs2_free_quota_recovery(qrec); |
@@ -1408,8 +1405,7 @@ bail: | |||
1408 | 1405 | ||
1409 | mutex_unlock(&osb->recovery_lock); | 1406 | mutex_unlock(&osb->recovery_lock); |
1410 | 1407 | ||
1411 | if (rm_quota) | 1408 | kfree(rm_quota); |
1412 | kfree(rm_quota); | ||
1413 | 1409 | ||
1414 | /* no one is callint kthread_stop() for us so the kthread() api | 1410 | /* no one is callint kthread_stop() for us so the kthread() api |
1415 | * requires that we call do_exit(). And it isn't exported, but | 1411 | * requires that we call do_exit(). And it isn't exported, but |
diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index a9f78c74d687..aebeacd807c3 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c | |||
@@ -476,8 +476,7 @@ out: | |||
476 | if (local_alloc_inode) | 476 | if (local_alloc_inode) |
477 | iput(local_alloc_inode); | 477 | iput(local_alloc_inode); |
478 | 478 | ||
479 | if (alloc_copy) | 479 | kfree(alloc_copy); |
480 | kfree(alloc_copy); | ||
481 | } | 480 | } |
482 | 481 | ||
483 | /* | 482 | /* |
@@ -534,7 +533,7 @@ int ocfs2_begin_local_alloc_recovery(struct ocfs2_super *osb, | |||
534 | mlog_errno(status); | 533 | mlog_errno(status); |
535 | 534 | ||
536 | bail: | 535 | bail: |
537 | if ((status < 0) && (*alloc_copy)) { | 536 | if (status < 0) { |
538 | kfree(*alloc_copy); | 537 | kfree(*alloc_copy); |
539 | *alloc_copy = NULL; | 538 | *alloc_copy = NULL; |
540 | } | 539 | } |
@@ -1290,8 +1289,7 @@ bail: | |||
1290 | if (main_bm_inode) | 1289 | if (main_bm_inode) |
1291 | iput(main_bm_inode); | 1290 | iput(main_bm_inode); |
1292 | 1291 | ||
1293 | if (alloc_copy) | 1292 | kfree(alloc_copy); |
1294 | kfree(alloc_copy); | ||
1295 | 1293 | ||
1296 | if (ac) | 1294 | if (ac) |
1297 | ocfs2_free_alloc_context(ac); | 1295 | ocfs2_free_alloc_context(ac); |
diff --git a/fs/ocfs2/stack_o2cb.c b/fs/ocfs2/stack_o2cb.c index 94368017edb3..bf1f8930456f 100644 --- a/fs/ocfs2/stack_o2cb.c +++ b/fs/ocfs2/stack_o2cb.c | |||
@@ -376,7 +376,7 @@ static int o2cb_cluster_connect(struct ocfs2_cluster_connection *conn) | |||
376 | dlm_register_eviction_cb(dlm, &priv->op_eviction_cb); | 376 | dlm_register_eviction_cb(dlm, &priv->op_eviction_cb); |
377 | 377 | ||
378 | out_free: | 378 | out_free: |
379 | if (rc && conn->cc_private) | 379 | if (rc) |
380 | kfree(conn->cc_private); | 380 | kfree(conn->cc_private); |
381 | 381 | ||
382 | out: | 382 | out: |
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 0e91ec22a940..9b6910dec4ba 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c | |||
@@ -2525,8 +2525,7 @@ static int ocfs2_check_volume(struct ocfs2_super *osb) | |||
2525 | mlog_errno(status); | 2525 | mlog_errno(status); |
2526 | 2526 | ||
2527 | finally: | 2527 | finally: |
2528 | if (local_alloc) | 2528 | kfree(local_alloc); |
2529 | kfree(local_alloc); | ||
2530 | 2529 | ||
2531 | if (status) | 2530 | if (status) |
2532 | mlog_errno(status); | 2531 | mlog_errno(status); |
@@ -2553,8 +2552,7 @@ static void ocfs2_delete_osb(struct ocfs2_super *osb) | |||
2553 | * we free it here. | 2552 | * we free it here. |
2554 | */ | 2553 | */ |
2555 | kfree(osb->journal); | 2554 | kfree(osb->journal); |
2556 | if (osb->local_alloc_copy) | 2555 | kfree(osb->local_alloc_copy); |
2557 | kfree(osb->local_alloc_copy); | ||
2558 | kfree(osb->uuid_str); | 2556 | kfree(osb->uuid_str); |
2559 | ocfs2_put_dlm_debug(osb->osb_dlm_debug); | 2557 | ocfs2_put_dlm_debug(osb->osb_dlm_debug); |
2560 | memset(osb, 0, sizeof(struct ocfs2_super)); | 2558 | memset(osb, 0, sizeof(struct ocfs2_super)); |
diff --git a/fs/ocfs2/sysfile.c b/fs/ocfs2/sysfile.c index 3d635f4bbb20..f053688d22a3 100644 --- a/fs/ocfs2/sysfile.c +++ b/fs/ocfs2/sysfile.c | |||
@@ -91,8 +91,7 @@ static struct inode **get_local_system_inode(struct ocfs2_super *osb, | |||
91 | } else | 91 | } else |
92 | osb->local_system_inodes = local_system_inodes; | 92 | osb->local_system_inodes = local_system_inodes; |
93 | spin_unlock(&osb->osb_lock); | 93 | spin_unlock(&osb->osb_lock); |
94 | if (unlikely(free)) | 94 | kfree(free); |
95 | kfree(free); | ||
96 | } | 95 | } |
97 | 96 | ||
98 | index = (slot * NUM_LOCAL_SYSTEM_INODES) + | 97 | index = (slot * NUM_LOCAL_SYSTEM_INODES) + |