Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp895195yba; Thu, 18 Apr 2019 11:21:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjWUe8GT/6fab91IYMTEYy113dMJcNJ1LEqzD8mkFwdBw1QzLB4Ti9bWBbSfGkplDbiZSd X-Received: by 2002:a17:902:7841:: with SMTP id e1mr95402426pln.303.1555611717847; Thu, 18 Apr 2019 11:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611717; cv=none; d=google.com; s=arc-20160816; b=yQvaFhH1bZrRsbUch2ExhStvwV4/ldiWPIeFkQfa1k1I8vddXQIf/hGQ6mUMTTLTyU ak1NkcYTELqS16MK6uH0WqqtflHzbLXySZL6mOnL+ml1aQeHBmgQABqn54K4L//l0DPh mbSS6fjG1WIIL+c41PyP4XsZKpfdvhBBO/1r7YNHffSsY9ODuZqrRQBtlFpNpG1MthE0 5Tc0OXtzzfgw6RaIabzdX6qQ8BWqD/NeZMR/R51PrAFu3A7O7fNOawe+9gY2mNVwHSgp x6TikXnTSw4WziaNZ+fn6ZsjwyiZXNyeKT1cejH68rF+EDvVGCQ80AtNmVX1LWiOfOf3 h4Eg== 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=hI16/u9rPgGdcT8819OS93ig6QJ6eC69GFcHNkH49kU=; b=B7e03BKKnUees63Wynm4sE35BvIdBUrzHwE2Nyl2iGx2GhYOLwY7aN72VvEUAG+HZo kFYQCK6u5epUBqRghsF4M2Cyo+FQrtOkDfv5IP+cJTRZyxmpg6DSFNpim5Re20y4Gk+z kwwvrypd68rMarImZ6YXfXdOVmVC9LHtB5TzQTrNEmMxM1vHNEvuTGHT4vphWPXxAkxC 9C+Ya9C9zIJj8vk25d79Phza2g23JdB37z8SSF+/txk3JazsJzyIzFT5th8yTYEOZZmm DfDlWfTifi/crGjeFR1HNAdCbJmVMtbhyqwBKRpEhWsAhxZEfNFqcKUW+tfIcy36DQZl gFCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cvgAnKma; 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 q1si2843274pfh.125.2019.04.18.11.21.43; Thu, 18 Apr 2019 11:21:57 -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=cvgAnKma; 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 S2391797AbfDRSSz (ORCPT + 99 others); Thu, 18 Apr 2019 14:18:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:41952 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390151AbfDRSKQ (ORCPT ); Thu, 18 Apr 2019 14:10:16 -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 7A5FA20652; Thu, 18 Apr 2019 18:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555611016; bh=6l4S1EYGOcexUslv2KKPZ9DX/dz3UKDcpvTJJPKAVEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cvgAnKmaq9jopZSqecQv5M9Vm+fampAYpwSUZ72jHdcjvi0o2lWXDsluCa1Tv/q+6 49NxkQd3C3vrea4XljrIAYoE0yy5qN9B0JoDBvubalnUazQye8H7lAsNBOWHtuK2Jj umuc1atvLVeN11TMvYIB7a52gWCXLb44HeKp7u2I= 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 5.0 03/93] inotify: Fix fsnotify_mark refcount leak in inotify_update_existing_watch() Date: Thu, 18 Apr 2019 19:56:41 +0200 Message-Id: <20190418160437.127072723@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160436.781762249@linuxfoundation.org> References: <20190418160436.781762249@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 798f1253141a..3b7b8e95c98a 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