From patchwork Sat Mar 5 15:09:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 15894 X-Patchwork-Delegate: mareklindner@neomailbox.ch Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [127.0.0.1]) by open-mesh.org (Postfix) with ESMTP id A1A3A82417; Sat, 5 Mar 2016 16:09:56 +0100 (CET) Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=samS2lXd; dkim-adsp=fail (unprotected policy); dkim-atps=neutral Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=79.140.41.39; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=pass header.from=narfation.org Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id 476E6823A8 for ; Sat, 5 Mar 2016 16:09:31 +0100 (CET) Received: from sven-desktop.home.narfation.org (p200300C593C286FD0000000000002E16.dip0.t-ipconnect.de [IPv6:2003:c5:93c2:86fd::2e16]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id C6A6C110103; Sat, 5 Mar 2016 16:09:30 +0100 (CET) Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=narfation.org; s=20121; t=1457190570; bh=Yd5VRCc4OKUmVyjObpOkdYCYJQsTRfBfbY4Ye/m2B5o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=samS2lXdarEBg2Sq9EiqT/UK8OLgwiwVELf+ciWOYrlwXwORpcKTC4iQSJuGta8Cm KvqeiJVKeT2aJfrZ4Ozi5c452Mh8+41L89jiaCsRQZcm2HzD/1XwJO72Hf370XAZri bKT1qll3GayR0CtcWydIWGx/41vcQ3zSgLVyGKzI= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 5 Mar 2016 16:09:20 +0100 Message-Id: <1457190564-11419-5-git-send-email-sven@narfation.org> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1457190564-11419-1-git-send-email-sven@narfation.org> References: <1457190564-11419-1-git-send-email-sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCH 5/9] batman-adv: Use kref_get for batadv_tvlv_container_get X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" batadv_tvlv_container_get requires that tvlv.container_list_lock is held by the caller. It is therefore not possible that an item in tvlv.container_list has an reference counter of 0 and is still in the list The kref_get function instead WARNs (with debug information) when the reference counter would still be 0. This makes a bug in batman-adv better visible because kref_get_unless_zero would have ignored this problem. Signed-off-by: Sven Eckelmann --- net/batman-adv/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index bda5f13..1245a58 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -748,9 +748,7 @@ static struct batadv_tvlv_container if (tvlv_tmp->tvlv_hdr.version != version) continue; - if (!kref_get_unless_zero(&tvlv_tmp->refcount)) - continue; - + kref_get(&tvlv_tmp->refcount); tvlv = tvlv_tmp; break; }