Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp983763pxb; Fri, 22 Apr 2022 15:58:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxj5FqhY17TmlyOkvIwRBLLgfD9Z9Hu9z6RfcINElmK6TfWnS7z9b69MO8xULC4LoRU4EAz X-Received: by 2002:a63:5c0b:0:b0:382:76f4:c768 with SMTP id q11-20020a635c0b000000b0038276f4c768mr5678591pgb.93.1650668296516; Fri, 22 Apr 2022 15:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650668296; cv=none; d=google.com; s=arc-20160816; b=zgm+BIE1ZeCZlT0rkuYdSePimgKLUdXYpuGYeTz5iVf2ltcfJOVX3/RWk9guDKk7qO IkmJx+5pOZ2asRMLe0IlCdQCctJrGF+zs5cnTLWJ7tZzVB/ptOq8xvpROpSg0ngUG+W8 Vy+1llci2DcKMZanhx5o03fNvl4Otb2Sob2YokUB+PuJD5UruIjWd0nyOI6C7m9Adgqk i0pM0Avs0LN+xSsaUIvgQKBdvD+i02V85ffO2HXavrtAjblvVemntVU9tn21sPkFaLKz 2qbcIwVNHNp+3B/achBRPcn3XiwlLMn3zL/mOutBhjFwvjLr4b1i2JrtXEAAT52Cejx9 u2dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=g01tJpX+1sUJrShvusZ25PsNMnRVj5xBSlaI7IJ1xUQ=; b=EjZbdAskEDWNxcbNtlv9k3NEjDWqXB8K/qo5i7c76s3v13gWe8Zy3uPJRSg7atc1Gi NVFiJqryMwwqBF64wsfHDlLyN15WJRgmdfkAw3vD/c51dd+8aNzlmtUvf3C8jq3VcUyM WJ9cyQ0bUDmHtnwIe4J7KCN625+nCgVJQTsF27OLd7HMlsNQAFOgcdF9dv1Y4qWWp/xz cZhKewXtCd77i+doqX0LR7XAqmKxS4pTdE2ZkhIIY1i+TfKdvGGjFj6AwU9VlETzXQR1 bHHhe99o1YnuQgNL7OuIzoxPb73mWDWS2BQ6WWjvIv2gLKQuYjBQjbDSxw7N5BsY5XcA GOTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=mvnxrbbV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r9-20020a170902ea4900b00153b2d164e0si8838509plg.232.2022.04.22.15.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:58:16 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=mvnxrbbV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E887C37F2B7; Fri, 22 Apr 2022 15:03:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231549AbiDVWGC (ORCPT + 99 others); Fri, 22 Apr 2022 18:06:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231620AbiDVWFw (ORCPT ); Fri, 22 Apr 2022 18:05:52 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3603EFAD21 for ; Fri, 22 Apr 2022 13:49:12 -0700 (PDT) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 23MGZk40019136; Fri, 22 Apr 2022 20:05:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=g01tJpX+1sUJrShvusZ25PsNMnRVj5xBSlaI7IJ1xUQ=; b=mvnxrbbVXpitGlqiGtXYbaR+2eXCb4YE2sBg+edSMz5Sheu1gKJ1p3/fMhGYk5N+R2Ha S+DxE751yzK9lBGxTAa7xpc0V7/xro5VuhtAsphPBlw2Mwg20roZvhPccS4uDCs8JPt2 C44YYSY74g0gKWezeEmBtyzGF4R1hmNVd1NyrSLoy3ZOP55A6htJvZg2P4bTMUGzpa/j CICEJAq26SDqgZUcdH+X7IBB7Q1iMFd/kra5fF4Enbpm/gyrhBy7XqLN0YXg04cWoYUj A5sornFu+xaJ6UJ1ckZ4vtBeSofeqTQsjRnPaDug0mQ1+7jQlwtp9hDpWGHUJAGzBO3I oQ== Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0b-001b2d01.pphosted.com with ESMTP id 3fkvdv8jhr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Apr 2022 20:05:55 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 23MK1Vda000830; Fri, 22 Apr 2022 20:05:54 GMT Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by ppma04wdc.us.ibm.com with ESMTP id 3ffneaw6t8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 22 Apr 2022 20:05:54 +0000 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 23MK5sW528049704 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 22 Apr 2022 20:05:54 GMT Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0FF926A05A; Fri, 22 Apr 2022 20:05:54 +0000 (GMT) Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BB1B86A04D; Fri, 22 Apr 2022 20:05:52 +0000 (GMT) Received: from [9.160.2.163] (unknown [9.160.2.163]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP; Fri, 22 Apr 2022 20:05:52 +0000 (GMT) Message-ID: Date: Fri, 22 Apr 2022 13:05:51 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] powerpc/pci: Remove useless null check before call of_node_put() Content-Language: en-US To: Haowen Bai , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org References: <1650509529-27525-1-git-send-email-baihaowen@meizu.com> From: Tyrel Datwyler In-Reply-To: <1650509529-27525-1-git-send-email-baihaowen@meizu.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: K0jsygH_2k__2G2zY9heq5s1_kNUdsHt X-Proofpoint-ORIG-GUID: K0jsygH_2k__2G2zY9heq5s1_kNUdsHt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.858,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-04-22_06,2022-04-22_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 adultscore=0 priorityscore=1501 spamscore=0 clxscore=1011 phishscore=0 impostorscore=0 suspectscore=0 bulkscore=0 mlxscore=0 mlxlogscore=657 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2202240000 definitions=main-2204220085 X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/20/22 19:52, Haowen Bai wrote: > No need to add null check before call of_node_put(), since the > implementation of of_node_put() has done it. > > Signed-off-by: Haowen Bai > --- > arch/powerpc/kernel/pci_dn.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/powerpc/kernel/pci_dn.c b/arch/powerpc/kernel/pci_dn.c > index 61571ae23953..ba3bbc9bec2d 100644 > --- a/arch/powerpc/kernel/pci_dn.c > +++ b/arch/powerpc/kernel/pci_dn.c > @@ -357,8 +357,8 @@ void pci_remove_device_node_info(struct device_node *dn) > > /* Drop the parent pci_dn's ref to our backing dt node */ > parent = of_get_parent(dn); > - if (parent) > - of_node_put(parent); > + > + of_node_put(parent); This whole block of code looks useless, or suspect. Examining the rest of the code for this function this is the only place that parent is referenced. The of_get_parent() call returns the parent with its refcount incremented, and then we turn around and call of_node_put() which drops that reference we just took. The comment doesn't do what it says it does. If we really need to drop a previous reference to the parent device node this code block would need to call of_node_put() twice on parent to accomplish that. A closer examination is required to determine if what the comment says we need to do is required. If it is then the code as it exists today is leaking that reference AFAICS. -Tyrel > > /* > * At this point we *might* still have a pci_dev that was