Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2326215imm; Thu, 7 Jun 2018 08:50:10 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK5GKSTgIaQ9NORVdqqHUpw+vz6njgnSKSpa1/I0E1UWg3C1aKXqcWtEP6tYpoVdrYPzc/y X-Received: by 2002:a65:6319:: with SMTP id g25-v6mr2049550pgv.437.1528386610716; Thu, 07 Jun 2018 08:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528386610; cv=none; d=google.com; s=arc-20160816; b=I9tu8dLT0GgP+6oa1ev8nwdd5TwLQ6l1NvHn5jtmadQtmvCYJMosRpDkDO6EZlo6Av WuMakLg1hh2OLP792B1dPCaYjjTbkYlOkVw0+ZfGlk4cVzZdDnj2xK1/Cqpk7QZByTYL iflPETHQ70vpPDvCQAb/iKXlCYczuUgYeMk8Q78D/s58eeTXB2Gr7lWb1flw4uVlQiHx pmUbpKc3f6C5z+GQMYVp5Gt3VwCY2rPmXr6mMJuyuPkaZTpUSMuh3JGV1K8Yzeq5rgda 1Ei9AtsMTtIJK9sNM62oetYRyrAbK5iBE+v8+AiYWZByauM09wnV+Rqy9TfvXIZv7POz yClQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=sUGewOseWX7USdGYOE1aW8AOcaCM709AiLNfYyKc0Tc=; b=m442oyjG3X8/wk3VANKejyoRH7ZVqKCAF4ny+gktk/m0HXdKgHl88pbwFZjkny8dDv GJonHG05+3oddTb2eK6SLaJ21SBVND9et4z4pCnPPS8uZVRkm1TH6WE6kdK5TGa2V0kN 3E8bZGJjILpRepWnGVW57UbaBU9LVLIkwv9+GssINHRrfe0fql9tLsWTJKjt6xTi5ony Fxg/AaUQP7TTGA6vG64ghO0F+hOlcSd+O8mRXeR3zjktbL47Dww1wWpNeb3zVKF4HWNV 0RSxv62pxnnopaw4r3oB7dY0mychIArDdILO5HNpJwtMG9kvbtYclKwuIaJsYvyRSmyr nNeA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v18-v6si6900270pfg.343.2018.06.07.08.49.56; Thu, 07 Jun 2018 08:50:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934445AbeFGPsh (ORCPT + 99 others); Thu, 7 Jun 2018 11:48:37 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40535 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932779AbeFGOkL (ORCPT ); Thu, 7 Jun 2018 10:40:11 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbm-0005Zo-3z; Thu, 07 Jun 2018 15:09:46 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb4-0002x2-Dh; Thu, 07 Jun 2018 15:09:02 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Steve French" , "Namjae Jeon" , "Ashish Sangwan" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 170/410] cifs: fix memory leak when password is supplied multiple times In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Namjae Jeon commit d6ccf4997e62fb6629f9f003980dca5292138b7b upstream. 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 Signed-off-by: Steve French Signed-off-by: Ben Hutchings --- fs/cifs/connect.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -1614,6 +1614,7 @@ cifs_parse_mount_options(const char *mou 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; } @@ -1651,6 +1652,7 @@ cifs_parse_mount_options(const char *mou options = end; } + kfree(vol->password); /* Now build new password string */ temp_len = strlen(value); vol->password = kzalloc(temp_len+1, GFP_KERNEL);