From: Haris Iqbal <haris.iqbal@linux.dev>
To: Wentao Liang <vulab@iscas.ac.cn>, Jens Axboe <axboe@kernel.dk>,
stable@vger.kernel.org
Cc: Josh Law <objecting@objecting.org>, Kees Cook <kees@kernel.org>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] block: partitions: fix of_node refcount leak in of_partition()
Date: Tue, 26 May 2026 16:59:26 +0200 [thread overview]
Message-ID: <dbb8c50d-6478-466e-baff-20a6aeaca940@linux.dev> (raw)
In-Reply-To: <20260526102124.2283846-1-vulab@iscas.ac.cn>
On 5/26/26 12:21, Wentao Liang wrote:
> of_partition() calls of_node_get() on the parent device node at the
> beginning of the function, storing the reference in 'partitions_np'.
> This reference is leaked in two paths:
>
> 1. The compatibility check at the top of the function returns 0
> without releasing partitions_np when the node exists but is not
> "fixed-partitions" compatible.
>
> 2. The function returns 1 at the end after successfully processing
> all partitions without releasing partitions_np.
>
> Fix both leaks by adding of_node_put(partitions_np) on each path.
>
> Fixes: 2e3a191e89f9 ("block: add support for partition table defined in OF")
> Cc: stable@vger.kernel.org
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
Looks good:
Reviewed-by: Md Haris Iqbal <haris.iqbal@linux.dev>
> ---
> block/partitions/of.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/block/partitions/of.c b/block/partitions/of.c
> index c22b60661098..53664ea06b65 100644
> --- a/block/partitions/of.c
> +++ b/block/partitions/of.c
> @@ -74,8 +74,10 @@ int of_partition(struct parsed_partitions *state)
> struct device_node *partitions_np = of_node_get(ddev->of_node);
>
> if (!partitions_np ||
> - !of_device_is_compatible(partitions_np, "fixed-partitions"))
> + !of_device_is_compatible(partitions_np, "fixed-partitions")) {
> + of_node_put(partitions_np);
> return 0;
> + }
>
> slot = 1;
> /* Validate parition offset and size */
> @@ -104,5 +106,6 @@ int of_partition(struct parsed_partitions *state)
>
> seq_buf_puts(&state->pp_buf, "\n");
>
> + of_node_put(partitions_np);
> return 1;
> }
next prev parent reply other threads:[~2026-05-26 14:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 10:21 [PATCH] block: partitions: fix of_node refcount leak in of_partition() Wentao Liang
2026-05-26 14:59 ` Haris Iqbal [this message]
2026-05-26 16:36 ` Jens Axboe
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=dbb8c50d-6478-466e-baff-20a6aeaca940@linux.dev \
--to=haris.iqbal@linux.dev \
--cc=axboe@kernel.dk \
--cc=kees@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=objecting@objecting.org \
--cc=stable@vger.kernel.org \
--cc=vulab@iscas.ac.cn \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.