From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.kernel.org ([198.145.29.99]:34684 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932395AbeFIPcM (ORCPT ); Sat, 9 Jun 2018 11:32:12 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vlad Buslov , Roi Dayan , Jiri Pirko , Paul Blakey , "David S. Miller" Subject: [PATCH 4.16 07/48] cls_flower: Fix incorrect idr release when failing to modify rule Date: Sat, 9 Jun 2018 17:29:19 +0200 Message-Id: <20180609145948.147600514@linuxfoundation.org> In-Reply-To: <20180609145947.679103414@linuxfoundation.org> References: <20180609145947.679103414@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: stable-owner@vger.kernel.org List-ID: 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paul Blakey [ Upstream commit 8258d2da9f9f521dce7019e018360c28d116354e ] When we fail to modify a rule, we incorrectly release the idr handle of the unmodified old rule. Fix that by checking if we need to release it. Fixes: fe2502e49b58 ("net_sched: remove cls_flower idr on failure") Reported-by: Vlad Buslov Reviewed-by: Roi Dayan Acked-by: Jiri Pirko Signed-off-by: Paul Blakey Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/sched/cls_flower.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -974,7 +974,7 @@ static int fl_change(struct net *net, st return 0; errout_idr: - if (fnew->handle) + if (!fold) idr_remove(&head->handle_idr, fnew->handle); errout: tcf_exts_destroy(&fnew->exts);