Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3205844imb; Tue, 5 Mar 2019 03:43:26 -0800 (PST) X-Google-Smtp-Source: APXvYqw6YhM1OF34SwF+yB1YQGkArrFwzI0ADqXUcCjleFkYUBIqSDZKON5V2PqMEKUsya+fYyrM X-Received: by 2002:a62:41cc:: with SMTP id g73mr1388263pfd.145.1551786206649; Tue, 05 Mar 2019 03:43:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551786206; cv=none; d=google.com; s=arc-20160816; b=RbeH9o73c7BXgdNQ66u3XKfBQNmBuTKhLRWAco4AO2Or/7eqcT+wzVciqPCd0Z+voB mz27568zfzMGtHnkvIoadQOFmd35RRWUJotGPJo7VBcvFAJgkMoJmKBxHcoRwexy+tnb ChNlcGVPDe7JpSCx9GX+mIaLmHSiZfSFPROEG0MWgMJVWY9FhYnFzRDbYTih5qXYJalK pT2EJMb1KciaG2gMj4JPlAzQ7O0wG2TBoKiusWY3QJzPnnH0o9bhgZtenxGEtAEqYndx 9az0UVB6POs4r0V4S4o71QMik6I3/McIJ8a3iUrccFGmqnU3TGoFPNlMewo1DixUVxD8 3Ggw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=cjsHhJalwzEJjk0J0bDWA/Eixzr743EMPJ6TG/6uaXs=; b=rk8TZ+JCgqTGcnRaoUphIWPVeWLoUsoyJEk4NlGemwZzE1cTYALSIp0pZ9brLudYrm q5I5fdvlHs8KfaCo2R2K3MaLoSZXMHtlDoB4vT8iphLXCh5rYQLpRnWbzIZEdhoFASOP /xeNBn9CX12cWpdvIyTqBs3cLTzFDjcrEArlI+yMT3+pUnnsKJq0WiTd8LUF0zaqekP1 rCiIpXq7Yi4ht6h4t5b1k5eT/aq+emwtZ0UAMGPKz4Ic17XnAqrEUNToU848yhsuGTIX yQ924bnEu7IUsdF4+6yLH/qa55kY6ewg5emj4z0ulJmz2suyQosNx0nL40WSmYTJfqG0 0fbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=dL+AEf9M; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x9si7743048pfm.59.2019.03.05.03.43.10; Tue, 05 Mar 2019 03:43:26 -0800 (PST) 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=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=dL+AEf9M; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727819AbfCELky (ORCPT + 99 others); Tue, 5 Mar 2019 06:40:54 -0500 Received: from pandora.armlinux.org.uk ([78.32.30.218]:42606 "EHLO pandora.armlinux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727093AbfCELky (ORCPT ); Tue, 5 Mar 2019 06:40:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=cjsHhJalwzEJjk0J0bDWA/Eixzr743EMPJ6TG/6uaXs=; b=dL+AEf9MLmtrfMMiukk7SACDO Xd07FMEw79yWf6CYjG69/qBVG7zIuC9JYfHaUlIYuw/gWjYREw/g2Lx9+ZaV5WNMjRZ2eip8Hrp4/ aEHOXbsN648ABsa27LNJJW6mZSVGZocnqqtLrKDecC3GShXt1iDI2P9SDUvxwiSsWSHbIBSV9z4Cy 4RCMRnDaCwpXwQiwT6fYFkdT7zEDqN4wZTqjf4mMegLec+ex3FQ64IPHbbqhHjqj0HvgHNeGsuuGw yc5PO9iTgi5GJmIpTiX400d52UMiN2zRBT21HdSkP4EP6Tqgg04FbL5rTsZGkOH0B7mNqoGikeqex Nv3hp4Gtw==; Received: from shell.armlinux.org.uk ([2001:4d48:ad52:3201:5054:ff:fe00:4ec]:54946) by pandora.armlinux.org.uk with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1h18RH-0000yE-2J; Tue, 05 Mar 2019 11:40:51 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.89) (envelope-from ) id 1h18RF-0003AN-13; Tue, 05 Mar 2019 11:40:49 +0000 Date: Tue, 5 Mar 2019 11:40:48 +0000 From: Russell King - ARM Linux admin To: Wen Yang Cc: linux-kernel@vger.kernel.org, wang.yi59@zte.com.cn, Andreas =?iso-8859-1?Q?F=E4rber?= , Manivannan Sadhasivam , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 01/15] ARM: actions: fix a leaked reference by adding missing of_node_put Message-ID: <20190305114048.egpbeddy4pqbwl5b@shell.armlinux.org.uk> References: <1551785646-46173-1-git-send-email-wen.yang99@zte.com.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1551785646-46173-1-git-send-email-wen.yang99@zte.com.cn> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 05, 2019 at 07:33:52PM +0800, Wen Yang wrote: > The call to of_get_next_child returns a node pointer with refcount > incremented thus it must be explicitly decremented after the last > usage. > > Detected by coccinelle with the following warnings: > ./arch/arm/mach-actions/platsmp.c:112:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 103, but without a corresponding object release within this function. > ./arch/arm/mach-actions/platsmp.c:124:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 115, but without a corresponding object release within this function. > ./arch/arm/mach-actions/platsmp.c:137:3-9: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 128, but without a corresponding object release within this function. I question this. Your reasoning is that the node is no longer used so the reference count needs to be put. However, in all these cases, data is read from the nodes properties and the device remains in-use for the life of the kernel. There is a big difference here. With normal drivers, each device is bound to their associated device node associated with the device. When the device node goes away, then the corresponding device goes away too, which causes the driver to be unbound from the device. However, there is another class of "driver" which are the ones below, where they are "permanent" devices. These can never go away, even if the device node refcount hits zero and the device node is freed - the device is still present and in-use in the system. So, having the device node refcount hit zero is actually a bug: what that's saying is the system device (eg, SCU) has gone away. If you somehow were to remove the SCU from the system, you'd end up severing the connection between the CPU cores and the rest of the system - obviously resulting in a dead system! So, what is the point of dropping these refcounts for devices that can never go away - and thus their associated device_node should also never go away? > > Signed-off-by: Wen Yang > Reviewed-by: Florian Fainelli > Cc: "Andreas F?rber" > Cc: Manivannan Sadhasivam > Cc: Russell King > Cc: linux-arm-kernel@lists.infradead.org > Cc: linux-kernel@vger.kernel.org > --- > v2->v1: add a missing space between "adding" and "missing" > > arch/arm/mach-actions/platsmp.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/arm/mach-actions/platsmp.c b/arch/arm/mach-actions/platsmp.c > index 4fd479c..1a8e078 100644 > --- a/arch/arm/mach-actions/platsmp.c > +++ b/arch/arm/mach-actions/platsmp.c > @@ -107,6 +107,7 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus) > } > > timer_base_addr = of_iomap(node, 0); > + of_node_put(node); > if (!timer_base_addr) { > pr_err("%s: could not map timer registers\n", __func__); > return; > @@ -119,6 +120,7 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus) > } > > sps_base_addr = of_iomap(node, 0); > + of_node_put(node); > if (!sps_base_addr) { > pr_err("%s: could not map sps registers\n", __func__); > return; > @@ -132,6 +134,7 @@ static void __init s500_smp_prepare_cpus(unsigned int max_cpus) > } > > scu_base_addr = of_iomap(node, 0); > + of_node_put(node); > if (!scu_base_addr) { > pr_err("%s: could not map scu registers\n", __func__); > return; > -- > 2.9.5 > > -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up According to speedtest.net: 11.9Mbps down 500kbps up