Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1319102yba; Tue, 2 Apr 2019 06:48:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyFOSEXQa/1s3BfdLcqcm+1qiMY3b9/GmCSIcinU1JgZht0zNZPnz4x9S415ngCXTViMfuU X-Received: by 2002:a63:3fc2:: with SMTP id m185mr45215813pga.145.1554212889946; Tue, 02 Apr 2019 06:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554212889; cv=none; d=google.com; s=arc-20160816; b=Qfpx+zFGwNYWz3O4hy5DEjS6pzdepJ/cejy/dFyITHV+nGSkGpuixAHvMG3R8oDdGU WfrGXUJWW82vhzLK8lg+hFw7DmZgi5FBLo9wSE35VU2UP6YVVNslUftRpfVhQIUdpsb2 GrZbqjLNd9GiEniZiT6N/jJTzJNmToZExoH/WuPeNjYi6oZn0jvPDYJdZ7zYAwcDcm/D 6KuNllXX1NbtCcSJMQpAtQ+MZs394CXlt9NzebWx4Ee31X0i20/zJRJbNkWE5eHIjpBG rNQRKGyzKzt7OZnqPrJO1p0+M3nCs5FcecIrOuzP9wmZv9IsFN2U3kI5EhM036/HaDSi 5Ceg== 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; bh=34L0+h6ZlqZ5ipOOb9SdTjNTMGS65YHHlvIK85xUkOw=; b=w7IM0wrZ6amYheSG8g/rCY5fVPNZ1l7Sue6JpiBX3gSOCbhXWp0fTSIejRFAVTcUdq kelbYJgBj8wz/utW4S2RYQOW35dU9lKddScbcFF3OXH+GUCcG4XD5JJAQdsk708toPGk oP4WkPGSL8wBmIZJFrIPG+Z2SmmELvpR9pMlIm/a2jYWJIIwcLKccHO0dWzxDfuI7uFk hQ05dwDWOOAW2ln8u7cLpnv4bpriV03S6uLMW304dzJhe4hbJseKT5PauQFHaTTuukx0 nfUq4PGBPpthzrfglMjq4HPtdvSCjIgi4633dQHrfD60ZfMbyPDKUWxgq/Qmvb+j9WtH yWDw== 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 c14si3530561pls.106.2019.04.02.06.47.54; Tue, 02 Apr 2019 06:48:09 -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 S1731438AbfDBNkF (ORCPT + 99 others); Tue, 2 Apr 2019 09:40:05 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:42796 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731140AbfDBNkB (ORCPT ); Tue, 2 Apr 2019 09:40:01 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJdu-0002ma-77; Tue, 02 Apr 2019 14:39:58 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdt-0004r0-FV; Tue, 02 Apr 2019 14:39:57 +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, Denis Kirjanov , "David Teigland" , "Vasily Averin" Date: Tue, 02 Apr 2019 14:38:27 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 08/99] dlm: memory leaks on error path in dlm_user_request() In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.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.65-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Vasily Averin commit d47b41aceeadc6b58abc9c7c6485bef7cfb75636 upstream. According to comment in dlm_user_request() ua should be freed in dlm_free_lkb() after successful attach to lkb. However ua is attached to lkb not in set_lock_args() but later, inside request_lock(). Fixes 597d0cae0f99 ("[DLM] dlm: user locks") Signed-off-by: Vasily Averin Signed-off-by: David Teigland Signed-off-by: Ben Hutchings --- fs/dlm/lock.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) --- a/fs/dlm/lock.c +++ b/fs/dlm/lock.c @@ -5795,20 +5795,20 @@ int dlm_user_request(struct dlm_ls *ls, goto out; } } - - /* After ua is attached to lkb it will be freed by dlm_free_lkb(). - When DLM_IFL_USER is set, the dlm knows that this is a userspace - lock and that lkb_astparam is the dlm_user_args structure. */ - error = set_lock_args(mode, &ua->lksb, flags, namelen, timeout_cs, fake_astfn, ua, fake_bastfn, &args); - lkb->lkb_flags |= DLM_IFL_USER; - if (error) { + kfree(ua->lksb.sb_lvbptr); + ua->lksb.sb_lvbptr = NULL; + kfree(ua); __put_lkb(ls, lkb); goto out; } + /* After ua is attached to lkb it will be freed by dlm_free_lkb(). + When DLM_IFL_USER is set, the dlm knows that this is a userspace + lock and that lkb_astparam is the dlm_user_args structure. */ + lkb->lkb_flags |= DLM_IFL_USER; error = request_lock(ls, lkb, name, namelen, &args); switch (error) {