Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp779780pxb; Fri, 22 Apr 2022 11:00:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaQ9n0gkeumEop0frPt0N00r+xQt6WFGQchOlW7htmOy+nn4mkjyXGWxMfwOU5XTP3DZR5 X-Received: by 2002:a17:90b:1c10:b0:1d2:a7c4:3cf with SMTP id oc16-20020a17090b1c1000b001d2a7c403cfmr6773447pjb.100.1650650410757; Fri, 22 Apr 2022 11:00:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650650410; cv=none; d=google.com; s=arc-20160816; b=OzcpCjmYcMeGhmt4qNyGo63kuHZkdCXqh72cUmqKirT4cQcSlNnxlSFqrogRh18CKu Up1p1CCcy2g+4yFick4RJZj145nE9EKsR1hfaxbcUTkiwpimR3oAzEKNZwU4FDty7WvV UhAHbxO8bmXNa5NAzo2wruudyH9d5lzO4LX77N7wRtrpN4Zjm9Ew7Q2cCgbpOlRpHpNN 1xnB+vRF0/erMe4vAbCtcw6FyYfNl6jOVcd3slF/fhpr7gMBpTE8/PkQWf+k6G2uuvzv iqAdbTgQve3p08s3mKOsN+4AFhhch9GSk8t4NTCxMnf7fDnP1oTCY+bn1eVqb35UPNuh tRbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=hsIYTdMYpZPiXwEWJW1DqhM6DMAH+dTqFu/TCJc+yCI=; b=rgCeSCnJun67hEx/dtdA09qeT3GakuT1REKPbuIhChn69eUArlQ/STX/Bd/r3RsDwu DWw8vR08WsJeYJZujwitfZefOcoX3ubtsdWDceAl6cjUDKBz32q2EYI5So13PS+6Fy2Z gCMemEvmYiqZh+q8vO5N8Rd/PXocQlc6Zrq1GMFEDC9oRX6OEw1LkymeUBb+1M742lzr XmRBnuRj7ew4A5+G5X5+wBoMTaSU9LLK+aeIfjth54Mrd6w1LYIzfLHZr5ACqnz7ONeV ed5CUDcnCXHyX65XOdzDwi6b/6S98o3ForIIEwFp/4IXJIfvDLpyQzydOo5nquzv67OA ZK8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k6-20020a170902c40600b00153b2d16524si9893396plk.300.2022.04.22.11.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 11:00:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 73556113780; Fri, 22 Apr 2022 10:41:31 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348881AbiDSLzG (ORCPT + 99 others); Tue, 19 Apr 2022 07:55:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232714AbiDSLzF (ORCPT ); Tue, 19 Apr 2022 07:55:05 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF07A35AB6 for ; Tue, 19 Apr 2022 04:52:22 -0700 (PDT) Received: from canpemm500006.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KjMbF2F0vzfYt2; Tue, 19 Apr 2022 19:51:37 +0800 (CST) Received: from container.huawei.com (10.175.104.82) by canpemm500006.china.huawei.com (7.192.105.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 19 Apr 2022 19:52:20 +0800 From: Ziyang Xuan To: , , , , Subject: [PATCH] cocinelle: iterators: optimize device_node_continue rule Date: Tue, 19 Apr 2022 20:10:13 +0800 Message-ID: <20220419121013.1290398-1-william.xuanziyang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.82] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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 Execute the device_node_continue.cocci for kernel source. Get an error report as following: ./drivers/pci/hotplug/pnv_php.c:161:2-13: ERROR: probable double put. After analysis, we can find that it is false positive, because it is to detach the node from device tree. And we can abstract out an exception. Signed-off-by: Ziyang Xuan --- scripts/coccinelle/iterators/device_node_continue.cocci | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/coccinelle/iterators/device_node_continue.cocci b/scripts/coccinelle/iterators/device_node_continue.cocci index f8cd14dfa604..4b8ee3316a8c 100644 --- a/scripts/coccinelle/iterators/device_node_continue.cocci +++ b/scripts/coccinelle/iterators/device_node_continue.cocci @@ -49,9 +49,11 @@ for_each_node_with_property(n,e1) S & i@p1(...) { ... when != of_node_get(n) + when != of_detach_node(n) when any of_node_put@p2(n); - ... when any + ... when != of_detach_node(n) + when any } ) -- 2.25.1