From: Greg KH <gregkh@linuxfoundation.org>
To: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
Cc: rafael@kernel.org, dakr@kernel.org, Jonathan.Cameron@huawei.com,
kbusch@kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] node: fix a api misuse in node_init_node_access()
Date: Thu, 18 Dec 2025 12:23:27 +0100 [thread overview]
Message-ID: <2025121820-circus-jukebox-1295@gregkh> (raw)
In-Reply-To: <20251218085251.555749-1-lihaoxiang@isrc.iscas.ac.cn>
On Thu, Dec 18, 2025 at 04:52:51PM +0800, Haoxiang Li wrote:
> If device_register() fails, put_device() is the correct way to
> cleanup the resource.
> And free the dev name is unnecessary.
>
> Fixes: 08d9dbe72b1f ("node: Link memory nodes to their compute nodes")
> Cc: stable@vger.kernel.org
> Signed-off-by: Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>
> ---
> drivers/base/node.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/base/node.c b/drivers/base/node.c
> index 00cf4532f121..28c89ad67d0b 100644
> --- a/drivers/base/node.c
> +++ b/drivers/base/node.c
> @@ -170,14 +170,15 @@ static struct node_access_nodes *node_init_node_access(struct node *node,
> if (dev_set_name(dev, "access%u", access))
> goto free;
>
> - if (device_register(dev))
> - goto free_name;
> + if (device_register(dev)) {
> + put_device(dev);
> + return NULL;
> + }
>
> pm_runtime_no_callbacks(dev);
> list_add_tail(&access_node->list_node, &node->access_list);
> return access_node;
> -free_name:
> - kfree_const(dev->kobj.name);
> +
> free:
> kfree(access_node);
> return NULL;
> --
> 2.25.1
>
>
How was this found and tested?
prev parent reply other threads:[~2025-12-18 11:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 8:52 [PATCH] node: fix a api misuse in node_init_node_access() Haoxiang Li
2025-12-18 11:23 ` Greg KH [this message]
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=2025121820-circus-jukebox-1295@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=dakr@kernel.org \
--cc=kbusch@kernel.org \
--cc=lihaoxiang@isrc.iscas.ac.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=stable@vger.kernel.org \
/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