All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Abdurrahman Hussain <abdurrahman@nexthop.ai>
Cc: Saravana Kannan <saravanak@kernel.org>,
	Frank Rowand <frowand.list@gmail.com>,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	Sashiko AI <sashiko-bot@kernel.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH] of/overlay: don't pass the changeset's own id to of_overlay_remove()
Date: Mon, 28 Sep 2026 13:26:58 -0500	[thread overview]
Message-ID: <20260928182658.GA185307-robh@kernel.org> (raw)
In-Reply-To: <20260917-b4-of-overlay-remove-all-fix-v1-1-920441cecae2@nexthop.ai>

On Thu, Sep 17, 2026 at 07:28:16PM -0700, Abdurrahman Hussain wrote:
> of_overlay_remove_all() passes &ovcs->id to of_overlay_remove(), which
> zeroes *ovcs_id once the changeset is reverted, before calling
> free_overlay_changeset(). Through the aliased pointer that zeroes
> ovcs->id itself, so free_overlay_changeset()'s "ovcs->id > 0" guard
> is false and both idr_remove() and list_del() are skipped: the
> overlay_changeset is kfree()d while still linked in ovcs_list and
> registered in ovcs_idr.
> 
> Every overlay removed through of_overlay_remove_all() thus leaves a
> dangling list node and idr entry behind. The next ovcs_list iteration
> or idr lookup walks freed memory, and the ids are never returned to
> the idr. Nothing in-tree calls of_overlay_remove_all() today, but it
> is the documented API for removing every overlay in one go
> (Documentation/devicetree/overlay-notes.rst), so any module user hits
> this deterministically.
> 
> Pass a local copy of the id, like every other of_overlay_remove()
> caller does.

If every caller passes a local and updating the value is not needed, 
then we should just update the API to pass the value rather than a 
reference.

Additionally, if there are no callers we should perhaps just remove the 
API.

Rob

  reply	other threads:[~2026-09-28 18:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-18  2:28 [PATCH] of/overlay: don't pass the changeset's own id to of_overlay_remove() Abdurrahman Hussain
2026-09-28 18:26 ` Rob Herring [this message]
2026-09-28 21:05   ` Abdurrahman Hussain

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=20260928182658.GA185307-robh@kernel.org \
    --to=robh@kernel.org \
    --cc=abdurrahman@nexthop.ai \
    --cc=devicetree@vger.kernel.org \
    --cc=frowand.list@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=saravanak@kernel.org \
    --cc=sashiko-bot@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 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.