Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4690540pxu; Tue, 13 Oct 2020 05:03:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiWcgD+2sjLHiqzufwVTCHFUcxcraj2o/m3NNE1gXOeZRD5AX87vWzHt+It9xtuKxvB+vd X-Received: by 2002:aa7:dd4e:: with SMTP id o14mr19832196edw.203.1602590592192; Tue, 13 Oct 2020 05:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602590592; cv=none; d=google.com; s=arc-20160816; b=P1U0PGZMIxnnsySEOyD3FT2MA7WeXvI0IR4IJwD1RBv6a9LCyWBPezEdw/6eJ/Zu7O yJb9vRrahid5IWDaUcSvGWvVzChRck2FDBIrk7fyV7ecmN0W5WGNGB5oO6xfl9D6jM/C PIIli/TZX+I0ECJ0v8qjv/SjH+4u/R1m6FlIHxHfE23eAEDRMknkWBNYS0Rr0BkT00lL MP5n+2R6Z43Tm7uFbJG82JOu6TRns35r5bmhZg+nb0wGEykP4K5x3d5kKIjMG43FcEWl jVpyPzwcqIzo5Vqn+QAGbV44VcMid+jvftXiW9ZfGV+OIQDfNUjQRyKN9neeQMd3/MKG NV0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=gF+OlJTF7oc1cIHVaaQAHUSwiRwCmz1PE6XYhQ/M4F0=; b=jAI2VsQ9/VKAYHYtEyTyRE3QftATO5RXsukee6pq9GXAOLwT5ZkXZgk9vpclbUWpAV z5AiyB7QoRz8KJaqiXph3lpkHK+lbkJK/nZ4X5CsZFM0jke7/NMNnKPOzAl1V033o8Ix Ss3dAr+tKEEGuwLIRbJyCe6yzuWfR7R/dLaCvHxE3awUpzI7zZ7fLfd8OFr3gyugMQdM RVXs5RVMAQuTXgz6GEMA3NaMFdbjWDRfvxRkfiDZPwltK6JJiLN7nVo3k1JhxSKTBA/J /MQDBwV0dENf3EQ+RUjayHnrGOqzSVhH7AbapFjlZQeP4uzk6GGgDlwfO7+rfuvg2w/Z Qxmw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ss5si13456983ejb.737.2020.10.13.05.02.48; Tue, 13 Oct 2020 05:03:12 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729825AbgJMKaj (ORCPT + 99 others); Tue, 13 Oct 2020 06:30:39 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:62266 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729241AbgJMKai (ORCPT ); Tue, 13 Oct 2020 06:30:38 -0400 X-IronPort-AV: E=Sophos;i="5.77,370,1596492000"; d="scan'208";a="472338857" Received: from abo-173-121-68.mrs.modulonet.fr (HELO hadrien) ([85.68.121.173]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Oct 2020 12:30:36 +0200 Date: Tue, 13 Oct 2020 12:30:36 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Sumera Priyadarsini cc: cocci@systeme.lip6.fr, michal.lkml@markovi.net, nicolas.palix@imag.fr, linux-kernel@vger.kernel.org, Gilles.Muller@lip6.fr Subject: Re: [Cocci] [PATCH V2] coccinelle: iterators: Add for_each_child.cocci script In-Reply-To: <20201012171909.ihbx73evyj5dosxl@adolin> Message-ID: References: <20201012171909.ihbx73evyj5dosxl@adolin> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I have one more change to suggest. This one only affects the patch case, as the other cases just point to a problem but don't ompletely specify what to do about it. > +@ruleone depends on patch && !context && !org && !report@ > + > +local idexpression r.n; > +iterator r.i,i1; > +expression e; > +expression list [r.n1] es; > +statement S; > +@@ > + > + i(es,n,...) { > + ... > +( > + of_node_put(n); > +| > + e = n > +| > + return n; > +| > + i1(...,n,...) S > +| > ++ of_node_put(n); > +? return ...; > +) > + ... when any > + } There is one occurrence of the following code: for_each_available_child_of_node(search, child) { name = of_get_property(child, "regulator-compatible", NULL); if (!name) name = child->name; if (!strcmp(desc->of_match, name)) { of_node_put(search); return of_node_get(child); } } In this case, the for_each_available_child_of_node has incremented the reference count of child by 1, and then the return increments it again. It would be ok to put an of_not_put before the return, which is done by the above rule, but the code would be even simpler if it would just leave the reference count as is. So before the current return case, you can put another return case that does the following: - return of_node_get(n); + return n; julia