Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1697016pxb; Wed, 20 Oct 2021 09:59:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4dMazKOe79rluhaYUI2VDBNcQpGEW9hA2oAxjz88tg9oUHJjBZ+6yd8Hltoc7FXH1rZkp X-Received: by 2002:a17:902:db0e:b0:13e:f4d3:84c with SMTP id m14-20020a170902db0e00b0013ef4d3084cmr213355plx.2.1634749170027; Wed, 20 Oct 2021 09:59:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634749170; cv=none; d=google.com; s=arc-20160816; b=tir/NarC1W+nDO4IdHwwtoC1xBc8az0p1Ib0lavqmYen3jntiywg13Cbj+uq+p8fih Tm/NJjKT7NaU3m87H1TfLY6l25y+8y2M8ridZMYJaGHJJeHHbcXLOodpUiNJR3w1UFTd sRjFex5TbyC3OjXJ9sqct7/ybSMfykCHX7tPc0rZOTIaSwVmhpg2DOZQV1ZnUsQkdZEP mxPCxkmLb72c/5wHisWwi+UVil9yi47SjouwiO943ea+c23wlL0yEEOEZn51p0ROjewd 3/DB7ROW9CvuX116cZAFk4xDzwFlWZvhUrL/FU331KQ9S66IP3tjHDf+PWoQ6FGNYlcd Eyaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=trLzzqXQ74LpX5eCSDS2/sCA15hX4PPZwwXliX5rAYA=; b=RijZs6GmJ5OXFHt9yDqyHyFNMKUPo7Nqm95EVfCWmQHEruqx9A1mF0juDBoTpLfgIK zzjlSvgYzoXfSeLg9RxxCd/7QA1N563WvnxBhhmRVKJaL2MDBzWouaGdGxRV1RLV6BwI L/HUALC1t9KigZf7d5xf6OI3lLop8ol+cNjgROhG9QkINhanNSbWKJp0sqk/3S38eixC Zr9IYopPBwUETQvVwixnJyN27MLer3L/Se3b2ObA2K9tQA0ZMaxNcA7uwhOcgCnYxctp YYr8M5U7wNIon4tI0V4Aydz3E0gsSVxp8bd6dqrOemZ/0NqUZJKrH4JiSoqfEB5uu5TA 6YXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=lbzwgOun; 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=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id oc12si3074429pjb.38.2021.10.20.09.59.14; Wed, 20 Oct 2021 09:59:30 -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=@ibm.com header.s=pp1 header.b=lbzwgOun; 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=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230219AbhJTRAC (ORCPT + 99 others); Wed, 20 Oct 2021 13:00:02 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:64542 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230049AbhJTRAB (ORCPT ); Wed, 20 Oct 2021 13:00:01 -0400 Received: from pps.filterd (m0187473.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 19KGpe2d026736; Wed, 20 Oct 2021 12:57:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=trLzzqXQ74LpX5eCSDS2/sCA15hX4PPZwwXliX5rAYA=; b=lbzwgOunDHUq0I+y9yGzdHiSvzaLW6DFdIQw+Y9BE91X9nlg0WJWVELWMknKc10yecvW gjl1YA+RMA0zByaRogqh132LmJo7Fdl8hz5ErLF+snediK7tiPPM7F3LWBiqP+L1jny7 2Rq1yC8dQEvdAcF2rvgAi+7WMY+3n8KiGEGNYq39Tiap2IJ743OYtQJjTHueOKxpfti7 ZdGhghCGzLeND7cqmdiCte2MSlYV6QVf/BFTDzdtNh2JJGuIlXc4Ik+F+ODk2g/fhq2k T01mG+wpoP5tMned8mq3SwJ1TbW8GRnCtBk0JGlaw0qee7B+QHUl86cyFTaSsQcTO9AO +g== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com with ESMTP id 3btpg70vn8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Oct 2021 12:57:30 -0400 Received: from m0187473.ppops.net (m0187473.ppops.net [127.0.0.1]) by pps.reinject (8.16.0.43/8.16.0.43) with SMTP id 19KGs652031779; Wed, 20 Oct 2021 12:57:29 -0400 Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com with ESMTP id 3btpg70vmn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Oct 2021 12:57:29 -0400 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 19KGvSDq000882; Wed, 20 Oct 2021 16:57:28 GMT Received: from b03cxnp07029.gho.boulder.ibm.com (b03cxnp07029.gho.boulder.ibm.com [9.17.130.16]) by ppma04wdc.us.ibm.com with ESMTP id 3bqpcbspgp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 20 Oct 2021 16:57:28 +0000 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 19KGvQMq42336660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 20 Oct 2021 16:57:26 GMT Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A81F7C6073; Wed, 20 Oct 2021 16:57:26 +0000 (GMT) Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CC1A8C6062; Wed, 20 Oct 2021 16:57:24 +0000 (GMT) Received: from oc6857751186.ibm.com (unknown [9.65.235.71]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP; Wed, 20 Oct 2021 16:57:24 +0000 (GMT) Subject: Re: [PATCH] PCI/hotplug: Remove unneeded of_node_put() in pnv_php To: Nathan Lynch , Wan Jiabing Cc: kael_w@yeah.net, Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Bjorn Helgaas , linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, ajd@linux.ibm.com References: <20211020094604.2106-1-wanjiabing@vivo.com> <87tuhcx6v6.fsf@linux.ibm.com> From: Tyrel Datwyler Message-ID: <0622b8ea-7587-2e6b-5558-fae1847b14b9@linux.ibm.com> Date: Wed, 20 Oct 2021 09:57:23 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <87tuhcx6v6.fsf@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: UQqsjwRes6ukURU9LcuVM2CbxBr-x2Cg X-Proofpoint-ORIG-GUID: mfaW1Nz8f-BHa00nn_2yLtUZbY8oSQtP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.0.607.475 definitions=2021-10-20_05,2021-10-20_02,2020-04-07_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 impostorscore=0 clxscore=1015 bulkscore=0 phishscore=0 priorityscore=1501 spamscore=0 suspectscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2109230001 definitions=main-2110200092 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/20/21 4:39 AM, Nathan Lynch wrote: > Wan Jiabing writes: >> Fix following coccicheck warning: >> ./drivers/pci/hotplug/pnv_php.c:161:2-13: ERROR: probable double put. >> >> Device node iterators put the previous value of the index variable, so >> an explicit put causes a double put. > > I suppose Coccinelle doesn't take into account that this code is > detaching and freeing the nodes. > > >> diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c >> index f4c2e6e01be0..f3da4f95d73f 100644 >> --- a/drivers/pci/hotplug/pnv_php.c >> +++ b/drivers/pci/hotplug/pnv_php.c >> @@ -158,7 +158,6 @@ static void pnv_php_detach_device_nodes(struct device_node *parent) >> for_each_child_of_node(parent, dn) { >> pnv_php_detach_device_nodes(dn); >> >> - of_node_put(dn); >> of_detach_node(dn); >> } > > The code might be improved by comments explaining how the bare > of_node_put() corresponds to a "get" somewhere else in the driver, and > how it doesn't render the ongoing traversal unsafe. It looks suspicious > on first review, but I believe it's intentional and probably correct as > written. > This is a common usage pattern which if we put a comment about the pattern here we need to do it every where. I suppose a better solution is to wrap this put in a more descriptive function name like of_node_long_put() or something of the sort the makes it obvious we are dropping a long held global scope reference. -Tyrel