Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp633787ybz; Wed, 15 Apr 2020 15:35:05 -0700 (PDT) X-Google-Smtp-Source: APiQypL8xYF4G/amVWpb3PsxvcRGSyrn+GWrfeonVcF7uXENJUZXccvo8kVr5wjj9tJsype4XHQZ X-Received: by 2002:a17:906:70f:: with SMTP id y15mr7232040ejb.276.1586990105082; Wed, 15 Apr 2020 15:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586990105; cv=none; d=google.com; s=arc-20160816; b=r9teZhFnoofWUM7WRWKBEqkfj4y0LcN9S8I17a9QKgzKhK01Tpmy9VFWh9uHLeHDz0 SkZfvNND0pxYD3DUWOrWZN0tXFMMBZ4LLUcdQFuYltREyklyRIz6Jtj+AtSGS5H+jL07 oaz7TYEBG0GHPxZNv91EH4rstp71PMO3GImrDdnqzlit4wsiOJnj4GqNUU4t3byERkhC VzMp4AWRyuBOOcmRa6ZhezmRyGqGt5sww7t3N1IQwAq/pv6aUiIdQROl6v1iRSqd0Ohb 9ym6ntA3aapteIfzFejVXBWvijKwc9xYVMIR04Pz5dHJVr5zsLXp/Y4roEnKpq958WOu KF5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=OdG4JenZYuQ6SubtD8jAKOkRVrIevOaSd9jsn2zjJrw=; b=esL3rxLQ3yGQHnk87SwBK45qFTyADn6c9WvhmdNUypC/bjkCHUX3YK3tjp65PcEPwZ H1Gu+zQhoJWcheEJUw8BTMM+J25YXOI2CYnFfPCFN7DVOemUz7SmEM8WkysM0UjgcN5S 7cWbImFcJQVsrPaWJNgKn35R6oQXWTcAlj10CkXsg6LuoqJngXQu0Z4dLb4Abogrfdt9 SllA5qUBEzCw7+rPCE+n+b/WrUKugFtA/Q+UrGNSVKVFu52QDZbEl+ihCGGuREoxUHLD XxKnioXuuK3bJinzDIy0vZRdWgaYrF09JErMsN5b56PfzQ6zO8b6mjpr/LoGDngAAREd 4mkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fudan.edu.cn header.s=dkim header.b=MkExDy6L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fudan.edu.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id op2si11802380ejb.395.2020.04.15.15.34.42; Wed, 15 Apr 2020 15:35:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fudan.edu.cn header.s=dkim header.b=MkExDy6L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fudan.edu.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2408087AbgDOIep (ORCPT + 99 others); Wed, 15 Apr 2020 04:34:45 -0400 Received: from mail.fudan.edu.cn ([202.120.224.73]:43640 "EHLO fudan.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2408071AbgDOIeg (ORCPT ); Wed, 15 Apr 2020 04:34:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fudan.edu.cn; s=dkim; h=Received:From:To:Cc:Subject:Date: Message-Id; bh=OdG4JenZYuQ6SubtD8jAKOkRVrIevOaSd9jsn2zjJrw=; b=M kExDy6LJS0gvKwy6z3k4oYyr9K/y9RITg0sWY43l/+MuwuQZ9qbq+Km088wIscOw kvNjgtWMkSbRJZpCf+o3nmCJxYrRxuK7fSspXLesjdbPFELovEQltkQLiENkKErv dEyDD/lqGqoaS7TPBr8DULO4RetQj+FbtzGSXjEL8o= Received: from localhost.localdomain (unknown [120.229.255.108]) by app2 (Coremail) with SMTP id XQUFCgCnr4P9xpZeiEtZAA--.61S3; Wed, 15 Apr 2020 16:34:08 +0800 (CST) From: Xiyu Yang To: Marek Lindner , Simon Wunderlich , Antonio Quartulli , Sven Eckelmann , "David S. Miller" , Jakub Kicinski , b.a.t.m.a.n@lists.open-mesh.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: yuanxzhang@fudan.edu.cn, kjlu@umn.edu, Xiyu Yang , Xin Tan Subject: [PATCH] batman-adv: Fix refcnt leak in batadv_show_throughput_override Date: Wed, 15 Apr 2020 16:31:50 +0800 Message-Id: <1586939510-69461-1-git-send-email-xiyuyang19@fudan.edu.cn> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: XQUFCgCnr4P9xpZeiEtZAA--.61S3 X-Coremail-Antispam: 1UD129KBjvJXoW7Zw43KF45Cw17Cr43WFy7trb_yoW8GrWfpr Wjkr13Kr4vgw1DGwn0y3s8Wa4rAF43XFyUGF4rZ3WrArs5J3sayrySyFyjkr1UAFyrKw12 qF4avF98AFyDCFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9Y14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26rxl 6s0DM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s 0DM2vYz4IE04k24VAvwVAKI4IrM2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI 64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8Jw Am72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAG YxC7M4IIrI8v6xkF7I0E8cxan2IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4 AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE 17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMI IF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAIw20EY4v20xvaj40_WFyUJVCq 3wCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCT nIWIevJa73UjIFyTuYvjfUOlksUUUUU X-CM-SenderInfo: irzsiiysuqikmy6i3vldqovvfxof0/ Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org batadv_show_throughput_override() invokes batadv_hardif_get_by_netdev(), which gets a batadv_hard_iface object from net_dev with increased refcnt and its reference is assigned to a local pointer 'hard_iface'. When batadv_show_throughput_override() returns, "hard_iface" becomes invalid, so the refcount should be decreased to keep refcount balanced. The issue happens in the normal path of batadv_show_throughput_override(), which forgets to decrease the refcnt increased by batadv_hardif_get_by_netdev() before the function returns, causing a refcnt leak. Fix this issue by calling batadv_hardif_put() before the batadv_show_throughput_override() returns in the normal path. Signed-off-by: Xiyu Yang Signed-off-by: Xin Tan --- net/batman-adv/sysfs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c index 97736696d042..0f962dcd239e 100644 --- a/net/batman-adv/sysfs.c +++ b/net/batman-adv/sysfs.c @@ -1190,6 +1190,7 @@ static ssize_t batadv_show_throughput_override(struct kobject *kobj, tp_override = atomic_read(&hard_iface->bat_v.throughput_override); + batadv_hardif_put(hard_iface); return sprintf(buff, "%u.%u MBit\n", tp_override / 10, tp_override % 10); } -- 2.7.4