public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] media: atomisp: Fix memory leak in atomisp_fixed_pattern_table()
@ 2026-02-01  7:21 Zilin Guan
  2026-02-01  8:10 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Zilin Guan @ 2026-02-01  7:21 UTC (permalink / raw)
  To: hansg
  Cc: mchehab, sakari.ailus, andy, gregkh, hverkuil, linux-media,
	linux-kernel, linux-staging, jianhao.xu, Zilin Guan

atomisp_v4l2_framebuffer_to_css_frame() allocates memory for
raw_black_frame, which must be released via ia_css_frame_free().
However, if sh_css_set_black_frame() fails, the function returns
immediately without performing this cleanup, leading to a memory leak.

Fix this by assigning the error code to ret and allowing the code to
fall through to the ia_css_frame_free() call.

Compile tested only. Issue found using a prototype static analysis tool
and code review.

Fixes: 85b606e02ad7 ("media: atomisp: get rid of a bunch of other wrappers")
Signed-off-by: Zilin Guan <zilin@seu.edu.cn>
---
 drivers/staging/media/atomisp/pci/atomisp_cmd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index 3a4eb4f6d3be..208ff85cd7fb 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -3369,7 +3369,7 @@ int atomisp_fixed_pattern_table(struct atomisp_sub_device *asd,
 
 	if (sh_css_set_black_frame(asd->stream_env[ATOMISP_INPUT_STREAM_GENERAL].stream,
 				   raw_black_frame) != 0)
-		return -ENOMEM;
+		ret = -ENOMEM;
 
 	ia_css_frame_free(raw_black_frame);
 	return ret;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: atomisp: Fix memory leak in atomisp_fixed_pattern_table()
  2026-02-01  7:21 [PATCH] media: atomisp: Fix memory leak in atomisp_fixed_pattern_table() Zilin Guan
@ 2026-02-01  8:10 ` Greg KH
  2026-02-01 12:43   ` Zilin Guan
  0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2026-02-01  8:10 UTC (permalink / raw)
  To: Zilin Guan
  Cc: hansg, mchehab, sakari.ailus, andy, hverkuil, linux-media,
	linux-kernel, linux-staging, jianhao.xu

On Sun, Feb 01, 2026 at 07:21:07AM +0000, Zilin Guan wrote:
> atomisp_v4l2_framebuffer_to_css_frame() allocates memory for
> raw_black_frame, which must be released via ia_css_frame_free().
> However, if sh_css_set_black_frame() fails, the function returns
> immediately without performing this cleanup, leading to a memory leak.
> 
> Fix this by assigning the error code to ret and allowing the code to
> fall through to the ia_css_frame_free() call.
> 
> Compile tested only. Issue found using a prototype static analysis tool
> and code review.

Please properly document this as per the rules we have for using tools
like this.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] media: atomisp: Fix memory leak in atomisp_fixed_pattern_table()
  2026-02-01  8:10 ` Greg KH
@ 2026-02-01 12:43   ` Zilin Guan
  0 siblings, 0 replies; 3+ messages in thread
From: Zilin Guan @ 2026-02-01 12:43 UTC (permalink / raw)
  To: gregkh
  Cc: andy, hansg, hverkuil, jianhao.xu, linux-kernel, linux-media,
	linux-staging, mchehab, sakari.ailus, zilin

On Sun, Feb 01, 2026 at 09:10:12AM +0100, Greg KH wrote:
> On Sun, Feb 01, 2026 at 07:21:07AM +0000, Zilin Guan wrote:
> > atomisp_v4l2_framebuffer_to_css_frame() allocates memory for
> > raw_black_frame, which must be released via ia_css_frame_free().
> > However, if sh_css_set_black_frame() fails, the function returns
> > immediately without performing this cleanup, leading to a memory leak.
> > 
> > Fix this by assigning the error code to ret and allowing the code to
> > fall through to the ia_css_frame_free() call.
> > 
> > Compile tested only. Issue found using a prototype static analysis tool
> > and code review.
> 
> Please properly document this as per the rules we have for using tools
> like this.
> 
> thanks,
> 
> greg k-h

My apologies for the overly brief description regarding the tool and 
testing. I will follow the rules and provide a V2 patch with a properly 
documented commit message.

Best regards,
Zilin Guan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-01 12:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-01  7:21 [PATCH] media: atomisp: Fix memory leak in atomisp_fixed_pattern_table() Zilin Guan
2026-02-01  8:10 ` Greg KH
2026-02-01 12:43   ` Zilin Guan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox