From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F1EEC10F0E for ; Thu, 18 Apr 2019 18:18:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 579D820675 for ; Thu, 18 Apr 2019 18:18:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555611536; bh=6l4S1EYGOcexUslv2KKPZ9DX/dz3UKDcpvTJJPKAVEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=AEl3BpAJ7Y2e9dmAK+ok9L+G6yAXESZGIIFWhRmZ7PL+oBcw3vKoW90l7isjvZg3C oBnF/bTIAFujNILZ50nV9ee3xRekW5qfSPFVVb2Yd0Z9VTo0iQBnVurL9NqmjXvGMu 7uFYgOfJngNuIZQ3evVVPA3uX7e2ZYTwbeL0xTg0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391847AbfDRSSz (ORCPT ); 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