Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3730797imm; Mon, 8 Oct 2018 08:38:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV61sDA1MSa1DVsrOLN89ftdEFG+iTYTV2V0wSGQ7mc6v92OIUGUPSaaLM6H1dHS5BKRdhsq2 X-Received: by 2002:a63:4281:: with SMTP id p123-v6mr21289330pga.91.1539013094119; Mon, 08 Oct 2018 08:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539013094; cv=none; d=google.com; s=arc-20160816; b=xmK06Tpb7Tpf3fSPkxxOUgijI5lYPiDyVnLe3QxtuUjwxnSk4E9CIyURxZWIchaqVa CeEf/5wmm2MJpvkeRgPAznFd92EC6ubbMHibW5seELZSuqxxl9U3kUts+uPGo5YNhwf+ 5Zr0ym28zScar37XtZM/XoCleHzCvpq8EwoTRxrdvKP+ELzAk97aE4WZ/GiULK0onb1D pMF82RB8pWdB1q4BbWCubOwvyc0wZi0ooIXWicKCVrFDBE2lBSMwDOZeTd8II8XC/IlN pfcpuDxCflAjSzpSFozw8SSnESv9dGmv2rJq3/fO9Ib2lFp5v96XyKasZmkJ8wOalE7j A9AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=GuWxO5HW0aZyBTtMVJsuJfaAOaNok3KzK/xlDD+9fik=; b=SXtGnAWGgb7UT0LiAOYFZu9OBs/h0XvXURVAKktCiD3/b3Q/Y5McIQZB1QwnHlsp+H M24lY4VURvCMfa3/lUvSOSsbPT8t2cMDLLTswxvXZAbCNIsiPjejsuGpOB0X0KlbrXbL 7djSEsnNwpxH1POz2MNO86UewiJlIKbsRe0TX5aLivOty5+nEJVopK44cvAaXL2l9zYC 0W4DaeYQ/Mb/UpmTrujP3D+GVO3uO2GY3C/JxPkTPiKqaBXlpAaHtoqcRv8SWqkDaof1 EIGdiQcZopOsRn0TIK7gcyfZ/21BsAajcPHBpoVYrFYktTgWjSdmdA/B6CaGqurSzues GP9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=12V+c8R0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v124-v6si19106116pfv.1.2018.10.08.08.37.58; Mon, 08 Oct 2018 08:38:14 -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=12V+c8R0; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727016AbeJHWh4 (ORCPT + 99 others); Mon, 8 Oct 2018 18:37:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:56006 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726977AbeJHWhz (ORCPT ); Mon, 8 Oct 2018 18:37:55 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D32C0214C3; Mon, 8 Oct 2018 15:25:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539012340; bh=DIrmg0jUh6OrllmvX2UEViWB/FrLtlfpNfiyFkrC4Go=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=12V+c8R0JQMLThILj2SwtlF2OZe8pcEhxHlLLZreJJbib0hyTL/ZWCSQ8rAS+EBk8 U01vWDD8QG/bgV9iqAMCE7uSkLTHfAvxfk4p5x//WDrZKnHVXerTuy/QOirlxNNTDn fd9pq/kbzUggSxXn77a2bPvlG/+As724+a6sl9ag= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Marek Lindner , Sven Eckelmann , Simon Wunderlich , Sasha Levin Subject: [PATCH AUTOSEL 4.18 14/58] batman-adv: fix backbone_gw refcount on queue_work() failure Date: Mon, 8 Oct 2018 11:24:39 -0400 Message-Id: <20181008152523.70705-14-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181008152523.70705-1-sashal@kernel.org> References: <20181008152523.70705-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marek Lindner [ Upstream commit 5af96b9c59c72fb2af2d19c5cc2f3cdcee391dff ] The backbone_gw refcounter is to be decreased by the queued work and currently is never decreased if the queue_work() call fails. Fix by checking the queue_work() return value and decrease refcount if necessary. Signed-off-by: Marek Lindner Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Sasha Levin --- net/batman-adv/bridge_loop_avoidance.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index a2de5a44bd41..58c093caf49e 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -1772,6 +1772,7 @@ batadv_bla_loopdetect_check(struct batadv_priv *bat_priv, struct sk_buff *skb, { struct batadv_bla_backbone_gw *backbone_gw; struct ethhdr *ethhdr; + bool ret; ethhdr = eth_hdr(skb); @@ -1795,8 +1796,13 @@ batadv_bla_loopdetect_check(struct batadv_priv *bat_priv, struct sk_buff *skb, if (unlikely(!backbone_gw)) return true; - queue_work(batadv_event_workqueue, &backbone_gw->report_work); - /* backbone_gw is unreferenced in the report work function function */ + ret = queue_work(batadv_event_workqueue, &backbone_gw->report_work); + + /* backbone_gw is unreferenced in the report work function function + * if queue_work() call was successful + */ + if (!ret) + batadv_backbone_gw_put(backbone_gw); return true; } -- 2.17.1