Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp874556yba; Thu, 18 Apr 2019 11:01:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjoUBAKL5PAA/hGqRGrPgrELACABrd8Lx9pGAzuVQCSShcEal/66ntzGRRrqLzkH477Hp9 X-Received: by 2002:a17:902:a9c7:: with SMTP id b7mr93013926plr.145.1555610516793; Thu, 18 Apr 2019 11:01:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555610516; cv=none; d=google.com; s=arc-20160816; b=B49QHIPiTOLI4efuP3Rif3sc6aVK7LE2obzaZ+HbRlJDmjddjGaAvTaLSU/Tepz7mR H2n3c8oSy4123ZjK4L7EhXY1QK8nvpWO8oyS7urdXkX9Aj+2Zl53KcnFFM+vq/35NiAo MZVexsvTt3fMVC24D97twTVnCXnfn5+fhOfrvuZIO8KVSHsrFGYLhZ1pkPm8EQmpB5BV +Hfu9GV0dY1C5iOSae0GoKjxKrw83eLbfu+PMxEQpQ92Su9oWVw+e20JU+bt3sIQkaZf IZLQHNcuz7/UcJfJ1MfF9N1WFmoTXon/UlL2nU3tcLJqbhMAXa15lJh6WYYfvSMOsu+7 LY4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mAiV7OzsDA1zo3Iuo21syt9d7Ur24+SBkT4JZHrEVSA=; b=wN51BOcTT0N2SZP3bnbwX1o1LKXMTFYlVhY5RfaPUlCfmZDFp8t6Z3rB7cttJEcMdc tzhL+l6SSWK0bT4Mq2aKtakTItdbiOUx5v/+Yj5opejO/Ifd4VXafEt3pYW1ueCqqDeW iuoZYskf75yaY9cP+96OTlpzeNsWiAlTVOn1dBm/3ufJUcSghkEUTVz40ekrf63fjLXH aax0e0Hp78I2qkU/uOlf8abfeUzxSEX32W1SPf7ISSXm6f1ENc8CBRRcMVNWDvYleBMZ aA3dECclBAdP25OXjaZOb7ipiuVl60Dq0O93rGQn8S5f/JmGhR/YmfxL19XK4BA3ksTF v1iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aZhtWc13; 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 m3si2737743pfh.249.2019.04.18.11.01.41; Thu, 18 Apr 2019 11:01:56 -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; dkim=pass header.i=@kernel.org header.s=default header.b=aZhtWc13; 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 S2389955AbfDRR6s (ORCPT + 99 others); Thu, 18 Apr 2019 13:58:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:53058 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389928AbfDRR6r (ORCPT ); Thu, 18 Apr 2019 13:58:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D5D45206B6; Thu, 18 Apr 2019 17:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610326; bh=83fkPL9Lj6vVYKrV9g96lx8UFVsTllRcVRk/UrUpdcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aZhtWc13+KkzGSUuurXtEad2ARHptmyj7PYT/2Wl7zvmxQqx8/z91WaATHi8PSqdc SjoS9MI7if9fmRezRqtan5UAydkcnbN+s8KrBDuFBhGYPlIC9i0AwrXKTX6lRWnb84 jNzk7p6IrNt27iR5V7O/gLGy6LLc77fUcQqY2GhQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, ZhangXiaoxu , Jan Kara , Sasha Levin Subject: [PATCH 4.19 003/110] inotify: Fix fsnotify_mark refcount leak in inotify_update_existing_watch() Date: Thu, 18 Apr 2019 19:55:52 +0200 Message-Id: <20190418160437.823876738@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160437.484158340@linuxfoundation.org> References: <20190418160437.484158340@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 62c9d2674b31d4c8a674bee86b7edc6da2803aea ] Commit 4d97f7d53da7dc83 ("inotify: Add flag IN_MASK_CREATE for inotify_add_watch()") forgot to call fsnotify_put_mark() with IN_MASK_CREATE after fsnotify_find_mark() Fixes: 4d97f7d53da7dc83 ("inotify: Add flag IN_MASK_CREATE for inotify_add_watch()") Signed-off-by: ZhangXiaoxu Signed-off-by: Jan Kara Signed-off-by: Sasha Levin --- fs/notify/inotify/inotify_user.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/notify/inotify/inotify_user.c b/fs/notify/inotify/inotify_user.c index 780bba695453..97a51690338e 100644 --- a/fs/notify/inotify/inotify_user.c +++ b/fs/notify/inotify/inotify_user.c @@ -519,8 +519,10 @@ static int inotify_update_existing_watch(struct fsnotify_group *group, fsn_mark = fsnotify_find_mark(&inode->i_fsnotify_marks, group); if (!fsn_mark) return -ENOENT; - else if (create) - return -EEXIST; + else if (create) { + ret = -EEXIST; + goto out; + } i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark); @@ -548,6 +550,7 @@ static int inotify_update_existing_watch(struct fsnotify_group *group, /* return the wd */ ret = i_mark->wd; +out: /* match the get from fsnotify_find_mark() */ fsnotify_put_mark(fsn_mark); -- 2.19.1