From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753239AbdHTQg7 (ORCPT ); Sun, 20 Aug 2017 12:36:59 -0400 Received: from mout.web.de ([212.227.17.12]:52699 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753101AbdHTQg5 (ORCPT ); Sun, 20 Aug 2017 12:36:57 -0400 Subject: [PATCH 3/8] CIFS: One function call less in cifs_lookup() after error detection From: SF Markus Elfring To: linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, Steve French Cc: LKML , kernel-janitors@vger.kernel.org References: <826310e5-e01c-38af-90df-c5630f761a4d@users.sourceforge.net> Message-ID: <995e9d05-dd4e-cbe3-6686-60313ab97262@users.sourceforge.net> Date: Sun, 20 Aug 2017 18:36:54 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <826310e5-e01c-38af-90df-c5630f761a4d@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:hjTpjC1K8ggnViWctRB967WCVwuYcIt1COpX2pmk7ryvbBd+eIq gd6Tsp0LekFaOBr6VTeAA9H7PbJpyIJUzybqPOKtjFV5B9bby1gi+3tALMpPsE7FNBjmliD RcwE/f8pDhDAkeaAY4TmfCAAMQsbXPzNq3aRQR/8hDoJuyA5u8G9tp/yFAPLuLSBd7ldOm2 D5wIJgrJL5MsSYd4M7udw== X-UI-Out-Filterresults: notjunk:1;V01:K0:2T8o14tBe2U=:5ye185h4azi8lc6M9V0CWz 2j8XUEZEFecWRT7oPifwwkCX8W5bW+yf/cdV1x4nRCfCAvYkZvJBNetGL0ttjyAPK/E3MOuht vBTXKhAhe3XnCUcMkNxpPfP4cqPtEr2Xb4BDgKvQg7sNX9WoDlQRB4T9H+/avAPCyAL2kX5Bb UPUyCAIirfWQjFa17ZYUsnVfIwlkFmTsJh9ImjcJFtCjw1snN860F/2r4Mi1bHzs1m/5K9g53 845OSOS6aevvFjp35v01E4JEcfx0p2jbL2LJOM1uCm9pCVfbw+IbTx6SfCRdYIg86HykZg5dr eRvSDzjOHf2+5ObU2F5ttv7ksrO/RmznwcvPqifTEcy/dtyXuxxaix5kwOiLqACmJ9jK3lVmz nlh8s/xzj5U8n+lOFHmSP5vK9EZIMF+ayJdm5DV3gBAR05l71ryAI9hz6BQVlskJgyleQEiQX o+Jy+qgEhubmsZ0Gk6HgLZHEDz3C/GFwzz+sLgjqhM4EYc3jF+ubgi03g2VOi7lKf05jz6EKk EboE1x2Li+3xqnsRxajMnlb0zuZNqZuK4GhzbEdkI4rZXF7tNRkPePFdHG5V6T7aWHqDW/wA+ mtNcv7O4Xm16F/k4Rpu44rW8FLWoovhCHcvjeba+UjKz47aWr9rw/PU4nxxyG+rrv8HgBuxVJ +Vd4Qgkg6MSnltZHKHQirPdbysSjcR1DL1ltBF6zpZgHEx2WzIKoEFVSd44Sz0WD9+/fgb8cy J1HxYIvURGFczAdWJ32iH+Lly4GBoGQz3c4HdiuHIVqdvhX5Os+4mEvI0VjK9XGdcRAu84667 aIsNogQGdJ9d2ChyqrVur5GVIxOwvqHe87k0lK1OPXKfNVdwXg= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sun, 20 Aug 2017 16:26:44 +0200 The kfree() function was called in up to two cases by the cifs_lookup() function during error handling even if the passed variable contained a null pointer. * Adjust a jump target according to the Linux coding style convention. * Delete an initialisation for the variable "full_path" at the beginning which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- fs/cifs/dir.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 7dd7ca1afe0b..b43e535ced8a 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -759,7 +759,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, struct tcon_link *tlink; struct cifs_tcon *pTcon; struct inode *newInode = NULL; - char *full_path = NULL; + char *full_path; xid = get_xid(); @@ -778,7 +778,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, rc = check_name(direntry); if (rc) - goto lookup_out; + goto put_link; /* can not grab the rename sem here since it would deadlock in the cases (beginning of sys_rename itself) @@ -786,7 +786,7 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, full_path = build_path_from_dentry(direntry); if (full_path == NULL) { rc = -ENOMEM; - goto lookup_out; + goto put_link; } if (d_really_is_positive(direntry)) { @@ -823,8 +823,8 @@ cifs_lookup(struct inode *parent_dir_inode, struct dentry *direntry, is a common return code */ } -lookup_out: kfree(full_path); +put_link: cifs_put_tlink(tlink); free_xid(xid); return ERR_PTR(rc); -- 2.14.0