From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753241AbdHTQjQ (ORCPT ); Sun, 20 Aug 2017 12:39:16 -0400 Received: from mout.web.de ([212.227.17.12]:58789 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753101AbdHTQjO (ORCPT ); Sun, 20 Aug 2017 12:39:14 -0400 Subject: [PATCH 5/8] CIFS: Less function calls in cifs_mknod() 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: Date: Sun, 20 Aug 2017 18:39:11 +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:DVvG4LWI2gT76gBsibonohxGEPmwSJo6CRtURHNGO7TmVI9LgmG tEpj8zEwjvcuJy4x2N9TKGCOJyaXP+NxxRNpF/ud4V+ePhjS/xwgWtcSuEQytfMjuPyBLWO oEDGcYfIndCe9AEYkJVXT2w9QfbUjHMNhlER7tw+iPJDTLsBxYxrViN1Z+2k3jRKr0kFU0p LhMoRQIU4bmcVdZq/9ZPA== X-UI-Out-Filterresults: notjunk:1;V01:K0:7dOIQDWPvj4=:dYbzvQgjFllddYvD6GDbgU LQbAP+wF5084pZl6httOrfO7uZgiq8V+bvqJBy0BEHmYB494k8sRk5djvyfoR/XUDZ0/aMYpd nW1luCIuQAHfZCkPJUI4OmScoe6e+0sgPKVrjFGZwZsO/NvxDa22YqTUfVf5Vcloxf11SyPBF rXVCw2Zr8ZS0kFmJddoeFniQBLUl7Udr7RysmOVF9bbYnZWDaCDC8Eg0ZkZsoBgf1cdNi7Phr Xpg2em2QrsX6fjnAFMi6+0kfZwxPn2KDOd3ylDVF5MU/39XDAsdlYChLBM7YUBh1a2pHS59hG VoDfNX3Z8wQwxUw48PiugWoct4E2LX4fnaElFFt2LxPbzw8nvBFjKN4GIxvF3XdZIYfljiO3m D7iYM6pAE/9/Yu8ju9Whuu4gEsNBSShgd5ZALpW8jlUvN9AvZekGR67xClM9AxHtCzfEo7h/R kkKNRlWEgxx2MebMZeAVMZlJSNcGkGKLBvaV6MGewm67r/IdKsgDOgjQqw+jmmsT3t+qxFjy6 PLsSE+oLcj0GOaLH7X8D/OrjgAXF4HK7sNEyv1fWKSGaDbkgIjTUQrCg5Hh4LSZWbY9Eor2cW 7cSej3Lmd+Gmp4IYCG20rrk+sj06PC4b2gJ45beA+AQYUfk5R0dCczLLI4apTVAhxzEOnqupl /GUo9qeD8o1EvU//xiaLUnQbWvA8Si4gTB6VBem4eevRZKQt0R9vEGhMQV95kmou+YEu+V/H0 lWbxTu15t8qOWBjsktB1JvZBQ6atRCWo8qAWtPY+ZF9RXjTX/FkEvkiavXNDct84W1w+x2p2L I0AgNYiPzsLvdG6tyzbv45Iy7GVrHJGgbhNuiloaUz/JLT/QUI= 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:56:18 +0200 The kfree() function was called in a few cases by the cifs_mknod() function during error handling even if the passed variable contained a null pointer. * Adjust jump targets according to the Linux coding style convention. * Delete an initialisation for the variables "buf" and "full_path" which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- fs/cifs/dir.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c index 41039ab12643..2c9cbd8393d6 100644 --- a/fs/cifs/dir.c +++ b/fs/cifs/dir.c @@ -620,12 +620,12 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, struct tcon_link *tlink; struct cifs_tcon *tcon; struct cifs_io_parms io_parms; - char *full_path = NULL; + char *full_path; struct inode *newinode = NULL; __u32 oplock = 0; struct cifs_fid fid; struct cifs_open_parms oparms; - FILE_ALL_INFO *buf = NULL; + FILE_ALL_INFO *buf; unsigned int bytes_written; struct win_dev *pdev; struct kvec iov[2]; @@ -645,7 +645,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, full_path = build_path_from_dentry(direntry); if (full_path == NULL) { rc = -ENOMEM; - goto mknod_out; + goto put_link; } if (tcon->unix_ext) { @@ -667,18 +667,18 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, cifs_sb->local_nls, cifs_remap(cifs_sb)); if (rc) - goto mknod_out; + goto free_path; rc = cifs_get_inode_info_unix(&newinode, full_path, inode->i_sb, xid); if (rc == 0) d_instantiate(direntry, newinode); - goto mknod_out; + goto free_path; } if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) - goto mknod_out; + goto free_path; cifs_dbg(FYI, "sfu compat create special file\n"); @@ -708,7 +708,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, oplock = 0; rc = tcon->ses->server->ops->open(xid, &oparms, &oplock, buf); if (rc) - goto mknod_out; + goto free_buffer; /* * BB Do not bother to decode buf since no local inode yet to put @@ -740,9 +740,11 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode, /* FIXME: add code here to set EAs */ -mknod_out: - kfree(full_path); +free_buffer: kfree(buf); +free_path: + kfree(full_path); +put_link: cifs_put_tlink(tlink); free_id: free_xid(xid); -- 2.14.0