From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752737AbbGENg3 (ORCPT ); Sun, 5 Jul 2015 09:36:29 -0400 Received: from mout.web.de ([212.227.17.11]:60086 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751341AbbGENgV (ORCPT ); Sun, 5 Jul 2015 09:36:21 -0400 Message-ID: <559932D3.30403@users.sourceforge.net> Date: Sun, 05 Jul 2015 15:36:19 +0200 From: SF Markus Elfring User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Joel Becker , Mark Fasheh , ocfs2-devel@oss.oracle.com CC: LKML , kernel-janitors@vger.kernel.org, Julia Lawall Subject: [PATCH 07/11] ocfs2: Less function calls in ocfs2_shutdown_local_alloc() after error detection References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <5455FC05.4010606@users.sourceforge.net> <55992DF0.5030205@users.sourceforge.net> In-Reply-To: <55992DF0.5030205@users.sourceforge.net> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:zbLOu+iQ120TRWFVCAmF9U0wM5+bSptlWELuTfErt84XNEPjbnY 1lTLsuIVejzwOA8b70pDraQ+etbvEkiQxuj7ABf80dkWaqGKgGR8bg8HcRiUpZxleODKYxQ XISDVOteHutmuI9Okwb8YNf3RdExV+t47+UlTI+8GOAT2E+z6zF90kC05cQcNO3YpBL/Zb4 GoYKbw5OKkvLZt4eZYUmA== X-UI-Out-Filterresults: notjunk:1;V01:K0:YAQgA+HULL8=:bTvm2PNXSjHJSGRsEuu80m QO8lQs90ZZTuDrvAYpgaeK3L1W8WTWCckYaTEFac3uCe+nmM7CmHfZs8OKG2Nx+Rkul9+5Kwd GLrh4jV7o+k3fQiW94f5vymWiHMXmvxeXMfLFnl5Y7WGXE+dxvh51ZIU7l3/7+eK9zOt7FXba ySph4wqH5JntIYUfhrd/roa41NhJIgxOHEzOwIkUFbD5LwrEUqwRgS1q86wb4iZ4RnbcuCnYI mp2BwpetIai1TjBC1/2CHjRYJldbDS6FbbWrrX9p7d6tXInNNto9m9wcwdQcBXj0lSjhvJcPT jN6WBtpF5hPVWGVC9I2TmY0CeIdZR21tj6uiJi295NrNzph6EYrZGBsBbZVFpUhQS7P7hHZxn DNeJx+tDqAxR1nrCxGBURvwTruqqgxvYW5OobcU+d4LsmgGS12vrU/x2oWcAopLyLaTC3niEW zbis+G5o0daNutlCNT2k5cA9W84eQU1lPxa/kq4waacGrS2/fmhpqyZiL1q8S975o2TbprrV3 7QE2jNRj5sXzfMOh0+ocjrMKlqxUqHUHkSdheiPNYL/hpYt8TZiAc2OzE2FSBLoVMq1eyOyi+ ACPzGKXZCUZe6zVFMfjIII0LSWEpAn/9HDlyDewLfrVzWhbEDY3UImKpnLkdFVsuUsYKZxed2 Do2zCZKKC/2Q8EJzxpHdR7rj6NSUq3Hzpb8+tiasWXhbvGqxaAktjYqPHYvCeiLe+nXA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sat, 4 Jul 2015 21:02:05 +0200 The functions kfree() and iput() were called in a few cases by the ocfs2_shutdown_local_alloc() function during error handling even if the passed variables contained still a null pointer. * Return directly if the local allocation feature is unused or if a call for the ocfs2_get_system_file_inode() function failed. * Adjust jump targets. * Drop unnecessary initialisations for the variables "alloc", "alloc_copy", "bh", "local_alloc_inode" and "main_bm_inode" then. Signed-off-by: Markus Elfring --- fs/ocfs2/localalloc.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c index 16579ed..e6d5074 100644 --- a/fs/ocfs2/localalloc.c +++ b/fs/ocfs2/localalloc.c @@ -377,18 +377,18 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) { int status; handle_t *handle; - struct inode *local_alloc_inode = NULL; - struct buffer_head *bh = NULL; + struct inode *local_alloc_inode; + struct buffer_head *bh; struct buffer_head *main_bm_bh = NULL; - struct inode *main_bm_inode = NULL; - struct ocfs2_dinode *alloc_copy = NULL; - struct ocfs2_dinode *alloc = NULL; + struct inode *main_bm_inode; + struct ocfs2_dinode *alloc_copy; + struct ocfs2_dinode *alloc; cancel_delayed_work(&osb->la_enable_wq); flush_workqueue(ocfs2_wq); if (osb->local_alloc_state == OCFS2_LA_UNUSED) - goto out; + return; local_alloc_inode = ocfs2_get_system_file_inode(osb, @@ -397,7 +397,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) if (!local_alloc_inode) { status = -ENOENT; mlog_errno(status); - goto out; + return; } osb->local_alloc_state = OCFS2_LA_DISABLED; @@ -410,7 +410,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) if (!main_bm_inode) { status = -EINVAL; mlog_errno(status); - goto out; + goto put_local_alloc_inode; } mutex_lock(&main_bm_inode->i_mutex); @@ -443,7 +443,7 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) bh, OCFS2_JOURNAL_ACCESS_WRITE); if (status < 0) { mlog_errno(status); - goto out_commit; + goto free_copy; } ocfs2_clear_local_alloc(alloc); @@ -458,21 +458,18 @@ void ocfs2_shutdown_local_alloc(struct ocfs2_super *osb) if (status < 0) mlog_errno(status); +free_copy: + kfree(alloc_copy); out_commit: ocfs2_commit_trans(osb, handle); - out_unlock: brelse(main_bm_bh); - ocfs2_inode_unlock(main_bm_inode, 1); - out_mutex: mutex_unlock(&main_bm_inode->i_mutex); iput(main_bm_inode); - -out: +put_local_alloc_inode: iput(local_alloc_inode); - kfree(alloc_copy); } /* -- 2.4.5