From patchwork Thu Aug 21 10:11:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 4756321 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0C3279F344 for ; Thu, 21 Aug 2014 10:11:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 43C1120136 for ; Thu, 21 Aug 2014 10:11:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5DDEF2012F for ; Thu, 21 Aug 2014 10:11:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753786AbaHUKLY (ORCPT ); Thu, 21 Aug 2014 06:11:24 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:50610 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753627AbaHUKLX (ORCPT ); Thu, 21 Aug 2014 06:11:23 -0400 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NAN003E1IYWIL40@mailout1.samsung.com> for linux-cifs@vger.kernel.org; Thu, 21 Aug 2014 19:11:21 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [172.20.52.112]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 84.58.19786.8C5C5F35; Thu, 21 Aug 2014 19:11:20 +0900 (KST) X-AuditID: cbfee68e-b7fab6d000004d4a-a1-53f5c5c89ccb Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id FF.96.05196.8C5C5F35; Thu, 21 Aug 2014 19:11:20 +0900 (KST) Received: from DONAMJAEJEO06 ([10.88.104.63]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0NAN00FULIYW9F20@mmp1.samsung.com>; Thu, 21 Aug 2014 19:11:20 +0900 (KST) From: Namjae Jeon To: Steve French Cc: Shirish Pargaonkar , linux-cifs@vger.kernel.org, Pavel Shilovsky , Ashish Sangwan Subject: [PATCH v2] cifs: fix memory leak when password is supplied multiple times Date: Thu, 21 Aug 2014 19:11:20 +0900 Message-id: <002c01cfbd28$41411700$c3c34500$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: Ac+9J99540ecji+uQvS51vwlpsghlA== Content-language: ko X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrFIsWRmVeSWpSXmKPExsWyRsSkQPfE0a/BBrdOWFgsnXiJ2eLF/13M Fuf2slq8mNPAaPHmxWE2B1aPnbPusnvM3dXH6NG3ZRWjx+dNcgEsUVw2Kak5mWWpRfp2CVwZ q44cYi84yFHxvu8tUwPjDbYuRk4OCQETiZeLnzNB2GISF+6tB4sLCSxllFh0Thmm5vPLvaxd jFxA8UWMEn8PTGeBcP4ySrw7uxmog4ODTUBb4s8WUZAGEQFViXfNU5lBapgFljBK7H25iBEk ISwQIvFl+kqwDSxARf8/NYDFeQUsJZ7uusQEYQtK/Jh8jwXEZhbQkti8rYkVwpaX2LzmLTPE RQoSO86+ZoRYpiexeMJWRogaEYl9L94xgiyWENjGLnHo2BcWiGUCEt8mH2IBOVRCQFZi0wGo OZISB1fcYJnAKDYLyepZSFbPQrJ6FpIVCxhZVjGKphYkFxQnpRcZ6RUn5haX5qXrJefnbmIE xtvpf8/6djDePGB9iDEZaP1EZinR5HxgvOaVxBsamxlZmJqYGhuZW5qRJqwkz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R7LVuQzvPknurDOSYqgSH3d2e6Bn6IuZ57UkTb8+VtsRWO SizFGYmGWsxFxYkAmp02YP0CAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Unlikely but possible. When password is supplied multiple times, we have to free the previous allocation. Signed-off-by: Namjae Jeon Signed-off-by: Ashish Sangwan --- Changelog v2: - fix a possible double free reported by kbuild. fs/cifs/connect.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index b4b6d10..8a9fded 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1587,6 +1587,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, tmp_end++; if (!(tmp_end < end && tmp_end[1] == delim)) { /* No it is not. Set the password to NULL */ + kfree(vol->password); vol->password = NULL; break; } @@ -1624,6 +1625,7 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, options = end; } + kfree(vol->password); /* Now build new password string */ temp_len = strlen(value); vol->password = kzalloc(temp_len+1, GFP_KERNEL);