From patchwork Sat May 24 12:42:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shilovsky X-Patchwork-Id: 4237461 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 0ECCD9F336 for ; Sat, 24 May 2014 12:42:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 361DA2037A for ; Sat, 24 May 2014 12:42:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 154C120306 for ; Sat, 24 May 2014 12:42:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751195AbaEXMmO (ORCPT ); Sat, 24 May 2014 08:42:14 -0400 Received: from mail-lb0-f169.google.com ([209.85.217.169]:45343 "EHLO mail-lb0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751138AbaEXMmN (ORCPT ); Sat, 24 May 2014 08:42:13 -0400 Received: by mail-lb0-f169.google.com with SMTP id s7so3358079lbd.14 for ; Sat, 24 May 2014 05:42:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=C4hKFw5cW4eDwAo0PmvuvSvlFJaCiUo3/u+2spiJvDU=; b=GYdEmXdDSTMR2YVZlj+6D01R+OJbg4RasQRlwXoYL9C6UrUd+oC5XLWzPjX8rMJPvC q7rz9VXk/UhpBez4/MHxtFuRNhUFqtAxGfySaNlScGlcOUHe8ISM6Q8lHKEGT7BroAaf Uq1HJ8+fRKJ/YooYcKveTzE8WSrM3HHnutlOYoAKrf97mUSeLICYQpVCk2ub5JHvnYGF JRg371JO8S3JyVok+zyZ/Pd5/VhqDnoWtiigzC2Wo/Jkp7pDT9oetYkMqkvxJbUwrR24 pbx6JrIusFD6KfOX2eRdIcwnwfxCigsruuttyfalPsUw9jsHlxeRuZX8dQYZ2iWnZIWC taIg== X-Received: by 10.112.85.167 with SMTP id i7mr7766999lbz.32.1400935331682; Sat, 24 May 2014 05:42:11 -0700 (PDT) Received: from localhost.localdomain ([92.43.3.3]) by mx.google.com with ESMTPSA id z1sm5215595lal.6.2014.05.24.05.42.09 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 24 May 2014 05:42:10 -0700 (PDT) From: Pavel Shilovsky To: linux-cifs@vger.kernel.org Cc: stable@vger.kernel.org Subject: [PATCH] CIFS: Fix memory leaks in SMB2_open Date: Sat, 24 May 2014 16:42:02 +0400 Message-Id: <1400935322-5157-1-git-send-email-pshilovsky@samba.org> X-Mailer: git-send-email 1.7.10.4 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.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 Cc: # v3.12+ Signed-off-by: Pavel Shilovsky Reviewed-by: Shirish Pargaonkar --- fs/cifs/smb2pdu.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index b0037b6..b0b260d 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -1097,6 +1097,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, int rc = 0; unsigned int num_iovecs = 2; __u32 file_attributes = 0; + char *dhc_buf = NULL, *lc_buf = NULL; cifs_dbg(FYI, "create/open\n"); @@ -1163,6 +1164,7 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, kfree(copy_path); return rc; } + lc_buf = iov[num_iovecs-1].iov_base; } if (*oplock == SMB2_OPLOCK_LEVEL_BATCH) { @@ -1177,9 +1179,10 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, if (rc) { cifs_small_buf_release(req); kfree(copy_path); - kfree(iov[num_iovecs-1].iov_base); + kfree(lc_buf); return rc; } + dhc_buf = iov[num_iovecs-1].iov_base; } rc = SendReceive2(xid, ses, iov, num_iovecs, &resp_buftype, 0); @@ -1211,6 +1214,8 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, *oplock = rsp->OplockLevel; creat_exit: kfree(copy_path); + kfree(lc_buf); + kfree(dhc_buf); free_rsp_buf(resp_buftype, rsp); return rc; }