mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Sakari Ailus" <sakari.ailus@linux.intel.com>,
	"Arnd Bergmann" <arnd@kernel.org>
Cc: "Cosmin Tanislav" <cosmin.tanislav@analog.com>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Hans Verkuil" <hverkuil+cisco@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: i2c: maxim-serdes: reduce max_des_update_streams() stack usage
Date: Thu, 15 Oct 2026 08:45:26 +0200	[thread overview]
Message-ID: <5b26153a-768a-4b33-bda3-19d3dea88634@app.fastmail.com> (raw)
In-Reply-To: <as9okp5GgBgc5Hlp@kekkonen.localdomain>

On Wed, Oct 14, 2026, at 13:33, Sakari Ailus wrote:
> On Wed, Oct 14, 2026 at 12:31:33PM +0200, Arnd Bergmann wrote:
>>  			return ret;
>> @@ -2450,18 +2453,21 @@ static int max_des_update_streams(struct v4l2_subdev *sd,
>>  				  u32 pad, u64 updated_streams_mask, bool enable)
>>  {
>>  	struct max_des_priv *priv = v4l2_get_subdevdata(sd);
>> -	struct max_des_remap_context context = { 0 };
>> +	struct max_des_remap_context *context __free(kfree) = kzalloc_obj(*context);
>
> max_des_update_streams() is used in implementing disable_streams()
> sub-device pad op where meaningful error handling isn't possible.
>
> It seems there are other ways it can fail but this adds one more.

Right. I see there are more allocations in max_des_update_pipe_remaps(),
and max_des_update_pipe_vc_remaps() called through max_des_update_links()
that could fail as well, and may have the additional problem of
leaking allocations every time a stream is enabled and disabled.

Can you tell if those should be fixed as well?

> The bulk of the struct consists of the vc_ids_map unsigned int array, but
> the maximum value VCs can have is 31. Also the size of unsigned long
> depends on the architecture, so a fixed-size type would be probably a
> better choice.
>
> Also using bit fields instead of bool would save space.

That would likely bring it under the warning limit, but I wonder
if there is another way to avoid the stack allocation entirely.

Are ->enable_streams() and ->disable_streams() always serialized
or can they be called concurrently on the same subdev? If there
is only one of them at a time, the allocation could just be
done ahead of time in max_des_allocate().

      Arnd

  reply	other threads:[~2026-10-15  6:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 10:31 Arnd Bergmann
2026-10-14 11:33 ` Sakari Ailus
2026-10-15  6:45   ` Arnd Bergmann [this message]
2026-10-15  9:40     ` Sakari Ailus
2026-10-15  9:48       ` Sakari Ailus
2026-10-15 10:06       ` Arnd Bergmann

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=5b26153a-768a-4b33-bda3-19d3dea88634@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=cosmin.tanislav@analog.com \
    --cc=hverkuil+cisco@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®