Netdev List
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: "zhangzekun (A)" <zhangzekun11@huawei.com>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	robh@kernel.org, saravanak@google.com, justin.chen@broadcom.com,
	florian.fainelli@broadcom.com, andrew+netdev@lunn.ch,
	kuba@kernel.org, kory.maincent@bootlin.com,
	jacopo+renesas@jmondi.org,
	kieran.bingham+renesas@ideasonboard.com, maddy@linux.ibm.com,
	mpe@ellerman.id.au, npiggin@gmail.com, olteanv@gmail.com,
	davem@davemloft.net, taras.chornyi@plvision.eu,
	edumazet@google.com, pabeni@redhat.com, sudeep.holla@arm.com,
	cristian.marussi@arm.com, arm-scmi@vger.kernel.org,
	linuxppc-dev@lists.ozlabs.org, linux-media@vger.kernel.org,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	chenjun102@huawei.com, Joe Hattori <joe@pf.is.s.u-tokyo.ac.jp>
Subject: Re: [PATCH 1/9] of: Add warpper function of_find_node_by_name_balanced()
Date: Sat, 8 Feb 2025 07:18:52 +0300	[thread overview]
Message-ID: <be93486b-91bb-4fdd-9f6c-ec295c448476@stanley.mountain> (raw)
In-Reply-To: <20250207153722.GA24886@pendragon.ideasonboard.com>

[-- Attachment #1: Type: text/plain, Size: 740 bytes --]

On Fri, Feb 07, 2025 at 05:37:22PM +0200, Laurent Pinchart wrote:
> I'm tempted to then rename of_find_node_by_name() to
> __of_find_node_by_name() to indicate it's an internal function not meant
> to be called except in special cases. It could all be renamed to
> __of_find_next_node_by_name() to make its behaviour clearer.
> 

Adding "next" to the name would help a lot.

Joe Hattori was finding some of these bugs using his static checker.
We could easily write something really specific to find this sort of
bug using Smatch.  If you have ideas like this feel free to ask on
smatch@vger.kernel.org.  It doesn't find anything that your grep
didn't find but any new bugs will be detected when they're introduced.

regards,
dan carpenter

[-- Attachment #2: err-list --]
[-- Type: text/plain, Size: 426 bytes --]

drivers/net/ethernet/broadcom/asp2/bcmasp.c:1370 bcmasp_probe() warn: 'dev->of_node' was not incremented
drivers/net/pse-pd/tps23881.c:505 tps23881_get_of_channels() warn: 'priv->np' was not incremented
drivers/media/platform/qcom/venus/core.c:301 venus_add_video_core() warn: 'dev->of_node' was not incremented
drivers/regulator/tps6594-regulator.c:618 tps6594_regulator_probe() warn: 'tps->dev->of_node' was not incremented

[-- Attachment #3: check_of_find_node_by_name.c --]
[-- Type: text/x-csrc, Size: 1176 bytes --]

/*
 * Copyright 2025 Linaro Ltd.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt
 */

#include "smatch.h"

static int my_id;

static void of_find_node_by_name(struct expression *expr, const char *name, struct symbol *sym, void *data)
{
	if (!refcount_was_inced_name_sym(name, sym, "->kobj.kref.refcount.refs.counter"))
		sm_warning("'%s' was not incremented", name);
}

void check_of_find_node_by_name(int id)
{
	my_id = id;

	if (option_project != PROJ_KERNEL)
		return;

	add_function_param_key_hook_early("of_find_node_by_name", &of_find_node_by_name, 0, "$", NULL);
}

  reply	other threads:[~2025-02-08  4:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-07  1:31 [PATCH 0/9] Add wrapper function of_find_node_by_name_balanced() Zhang Zekun
2025-02-07  1:31 ` [PATCH 1/9] of: Add warpper " Zhang Zekun
2025-02-07  8:24   ` Oleksij Rempel
2025-02-07  8:57     ` Laurent Pinchart
2025-02-07 11:28     ` zhangzekun (A)
2025-02-07 15:37       ` Laurent Pinchart
2025-02-08  4:18         ` Dan Carpenter [this message]
2025-04-25 15:30           ` Dan Carpenter
2025-04-25 17:07             ` Laurent Pinchart
2025-06-10 19:39               ` Andy Shevchenko
2025-06-10 20:03                 ` Laurent Pinchart
2025-06-10 20:17                   ` Andy Shevchenko
2025-02-10  6:47         ` zhangzekun (A)
2025-02-10 10:03           ` Laurent Pinchart
2025-02-11 11:26             ` zhangzekun (A)
2025-02-11 11:43               ` Laurent Pinchart
2025-02-11 14:15         ` Rob Herring
2025-02-12  5:47   ` Krzysztof Kozlowski
2025-02-07  1:31 ` [PATCH 2/9] net: bcmasp: Add missing of_node_get() before of_find_node_by_name() Zhang Zekun
2025-02-12  5:52   ` Krzysztof Kozlowski
2025-02-12  6:50     ` zhangzekun (A)
2025-02-07  1:31 ` [PATCH 3/9] net: pse-pd: " Zhang Zekun
2025-02-07  1:31 ` [PATCH 4/9] media: max9286: Use of_find_node_by_name_balanced() to find device_node Zhang Zekun
2025-02-07  1:31 ` [PATCH 5/9] powerpc: " Zhang Zekun
2025-02-07  1:31 ` [PATCH 6/9] net: dsa: " Zhang Zekun
2025-02-07  1:31 ` [PATCH 7/9] net: dsa: hellcreek: " Zhang Zekun
2025-02-07  1:31 ` [PATCH 8/9] net: prestera: " Zhang Zekun
2025-02-07  1:31 ` [PATCH 9/9] regulator: scmi: " Zhang Zekun

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=be93486b-91bb-4fdd-9f6c-ec295c448476@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=arm-scmi@vger.kernel.org \
    --cc=chenjun102@huawei.com \
    --cc=cristian.marussi@arm.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=jacopo+renesas@jmondi.org \
    --cc=joe@pf.is.s.u-tokyo.ac.jp \
    --cc=justin.chen@broadcom.com \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=kory.maincent@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=maddy@linux.ibm.com \
    --cc=mpe@ellerman.id.au \
    --cc=netdev@vger.kernel.org \
    --cc=npiggin@gmail.com \
    --cc=o.rempel@pengutronix.de \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=robh@kernel.org \
    --cc=saravanak@google.com \
    --cc=sudeep.holla@arm.com \
    --cc=taras.chornyi@plvision.eu \
    --cc=zhangzekun11@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox