From patchwork Wed Mar 30 13:07:11 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Finney X-Patchwork-Id: 674172 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2UDl10g007083 for ; Wed, 30 Mar 2011 13:47:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755150Ab1C3Nq7 (ORCPT ); Wed, 30 Mar 2011 09:46:59 -0400 Received: from cobija.connexer.com ([66.93.22.232]:42422 "EHLO cobija.connexer.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755847Ab1C3Nq6 (ORCPT ); Wed, 30 Mar 2011 09:46:58 -0400 Received: by cobija.connexer.com (Postfix, from userid 1000) id A971617CC22; Wed, 30 Mar 2011 09:46:57 -0400 (EDT) Message-Id: <54430755071bdb37fe46abf3fda855bf35aaf891.1301492728.git.seanius@seanius.net> From: Sean Finney Date: Wed, 30 Mar 2011 15:07:11 +0200 Subject: [PATCH] Use kstrdup instead of manual string duplication for cifs_sb->mountdata To: linux-cifs@vger.kernel.org Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 30 Mar 2011 13:47:02 +0000 (UTC) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index fb6a2ad..e938bf0 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -134,24 +134,19 @@ cifs_read_super(struct super_block *sb, void *data, cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages; #ifdef CONFIG_CIFS_DFS_UPCALL - /* copy mount params to sb for use in submounts */ - /* BB: should we move this after the mount so we - * do not have to do the copy on failed mounts? - * BB: May be it is better to do simple copy before - * complex operation (mount), and in case of fail - * just exit instead of doing mount and attempting - * undo it if this copy fails?*/ + /* + * Copy mount params to sb for use in submounts. Better to do + * the copy here and deal with the error before cleanup gets + * complicated post-mount. + */ if (data) { - int len = strlen(data); - cifs_sb->mountdata = kzalloc(len + 1, GFP_KERNEL); + cifs_sb->mountdata = kstrdup(data, GFP_KERNEL); if (cifs_sb->mountdata == NULL) { bdi_destroy(&cifs_sb->bdi); kfree(sb->s_fs_info); sb->s_fs_info = NULL; return -ENOMEM; } - strncpy(cifs_sb->mountdata, data, len + 1); - cifs_sb->mountdata[len] = '\0'; } #endif