Re: [PATCH] staging: media: atomisp: refactor ia_css_stream_destroy
From: Dan Carpenter
Date: Thu Mar 26 2026 - 03:59:26 EST
On Thu, Mar 26, 2026 at 12:04:48AM +0100, Jose A. Perez de Azpillaga wrote:
> Refactor the ISP2401 cleanup logic into a separate helper
> function.
>
> Fix a logic bug where the loop variable 'i' was being shadowed and
> overwritten by a nested loop, potentially causing incorrect cleanup
> behavior.
This should be done separately and have a Fixes tag.
>
> Replace an early 'return -EINVAL' with 'continue' within the cleanup
> loop. In a destruction path, it is better to proceed with cleaning up as
> many resources as possible rather than aborting early, which would
> result in memory leaks for the remaining pipes.
>
> Remove 'assert(entry)' in favor of an explicit null pointer check ('if
> (!entry) continue;'). This avoids a macro-based assertions and ensuring
> the system remains stable even if a pointer is unexpectedly null during
> cleanup.
The assert in atomisp is a wrapper around BUG(). Add that to the commit
message.
You're going to have to redo this anyway because the i vs j fix needs
to be done separately as the first patch and it needs to have a Fixes
tag. I would kind of prefer if you did this as three patches:
patch 1: fix i vs j bug
patch 2: pull it into a separate function
patch 3: improve the function
It's easier for me to review that way.
regards,
dan carpenter