All of lore.kernel.org
 help / color / mirror / Atom feed
From: "D. Manresa" <dmanresa@gmail.com>
To: koreev.r@gmail.com, fernandorimoli11@gmail.com
Cc: sakari.ailus@linux.intel.com, dan.scally@ideasonboard.com,
	hansg@kernel.org, andriy.shevchenko@linux.intel.com,
	rillian.grant@gmail.com, lsa.uz@pm.me,
	linux-media@vger.kernel.org
Subject: Re: media: ipu-bridge: lifetime of retained software-node properties
Date: Mon, 26 Oct 2026 18:19:45 +0100	[thread overview]
Message-ID: <179303518584.774397.17279190841735842653@gmail.com> (raw)
In-Reply-To: <20261026111108.34186-1-fernandorimoli11@gmail.com>

On Mon, Oct 26, 2026 at 11:11:06AM +0000, Fernando Rimoli wrote:
> As far as I can see, with those two gone nothing in the graph points
> into the module any more and every other name and value is already a
> per-sensor copy.

I checked that instead of just agreeing with it, since Ruslan and Sergey
are both about to add properties and it is a bad thing to get wrong. It
holds, with one trap worth recording.

Against media/next with v5 applied, in ipu-bridge.c:

- every registered node's .name is a per-sensor or per-bridge char
  array: sensor->name, sensor->ivsc_name, sensor->node_names.*, and
  bridge->ipu_node_name for the IPU HID node itself;
- every property name comes from sensor->prop_names, a struct
  ipu_property_names of char arrays copied per sensor;
- every property value is an inline scalar, bridge->data_lanes,
  sensor->link_freqs (what 1/2 changes) or one of the sensor->*_ref
  arrays;
- there is no PROPERTY_ENTRY_STRING anywhere, so no property holds a
  string pointer as a value;
- .properties and .parent all point inside struct ipu_sensor or at
  bridge->ipu_hid_node.

All of that lives in the struct ipu_bridge that ipu_bridge_init()
allocates and then deliberately never frees: kfree(bridge) appears only
on the error paths, and there is no module_exit() or remove hook. So the
precise statement is not that nothing points into the module, but that
everything points into a heap allocation that outlives it. That is also
the answer to where a new name or value should go.

The trap: sensor->vcm_type still points into ipu_vcm_types[], which is
module rodata, and it survives in the retained struct. It is not a bug
today, because it is only read during init, and the one thing that runs
later -- ipu_bridge_instantiate_vcm() -- takes the VCM type from "%pfwP"
of the fwnode, that is from sensor->node_names.vcm, not from vcm_type.
But it is a dangling pointer sitting in a struct that outlives the
module, and the next person to read it from a rebind path will not
expect that. Either a comment or copying it like everything else would
close it.

If it helps: I have a Surface Pro 7+ (IPU6 Tiger Lake, three sensors on
the bridge) here for a few more days and can exercise the unload and the
PCI remove/rescan paths on it, which is where all of this actually
bites. Ask while it is still here.

D. Manresa

(Written with AI assistance, directed and reviewed by me. Resent as
plain text: the first copy was rejected by the list for carrying an HTML
part, so it reached the Cc list but never the archive. Apologies to
those getting it twice.)

  reply	other threads:[~2026-10-26 17:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-26  9:12 media: ipu-bridge: lifetime of retained software-node properties Ruslan Koreev
2026-10-26 11:11 ` Fernando Rimoli
2026-10-26 17:19   ` D. Manresa [this message]
2026-10-27 14:30     ` Ruslan Koreev
2026-10-27 19:21       ` D. Manresa

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=179303518584.774397.17279190841735842653@gmail.com \
    --to=dmanresa@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=dan.scally@ideasonboard.com \
    --cc=fernandorimoli11@gmail.com \
    --cc=hansg@kernel.org \
    --cc=koreev.r@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=lsa.uz@pm.me \
    --cc=rillian.grant@gmail.com \
    --cc=sakari.ailus@linux.intel.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 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.