Linux kernel staging patches
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Karthikey D Kadati <karthikey3608@gmail.com>
Cc: Hans de Goede <hansg@kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	linux-media@vger.kernel.org, linux-staging@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 RESEND v2 2/3] media: atomisp: consolidate statistics buffer allocation
Date: Wed, 7 Jan 2026 17:31:03 +0300	[thread overview]
Message-ID: <aV5uJ-bB6wQcq3s6@stanley.mountain> (raw)
In-Reply-To: <20260107134844.68074-3-karthikey3608@gmail.com>

On Wed, Jan 07, 2026 at 07:18:43PM +0530, Karthikey D Kadati wrote:
> Refactor atomisp_alloc_css_stat_bufs() to use a new helper function
> 
> atomisp_alloc_stat_bufs_list().
> 
> This reduces code duplication for allocating 3A, DIS, and metadata
> 
> buffers and centralizes the allocation loop logic.
> 
> The helper returns -ENOMEM on failure, triggering the existing
> 
> cleanup path in the caller which correctly frees any partially
> 
> allocated lists.
> 
> Signed-off-by: Karthikey D Kadati <karthikey3608@gmail.com>
> ---
>  .../staging/media/atomisp/pci/atomisp_ioctl.c | 123 ++++++++++++------
>  1 file changed, 81 insertions(+), 42 deletions(-)
> 
> diff --git a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
> index 5c0a1d92b..9e572b3e6 100644
> --- a/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp_ioctl.c
> @@ -678,13 +678,78 @@ static int atomisp_g_fmt_cap(struct file *file, void *fh,
>  	return atomisp_try_fmt_cap(file, fh, f);
>  }
>  
> +static int atomisp_alloc_stat_bufs_list(struct atomisp_sub_device *asd,
> +					u16 stream_id,
> +					struct list_head *buf_list,
> +					int count,
> +					enum ia_css_buffer_type type)
> +{
> +	struct atomisp_s3a_buf *s3a_buf;
> +	struct atomisp_dis_buf *dis_buf;
> +	struct atomisp_metadata_buf *md_buf;
> +
> +	while (count--) {
> +		switch (type) {
> +		case IA_CSS_BUFFER_TYPE_3A_STATISTICS:
> +			s3a_buf = kzalloc(sizeof(*s3a_buf), GFP_KERNEL);
> +			if (!s3a_buf)
> +				return -ENOMEM;
> +
> +			if (atomisp_css_allocate_stat_buffers(asd,
> +							      stream_id,
> +							      s3a_buf,
> +							      NULL,
> +							      NULL)) {
> +				kfree(s3a_buf);
> +				return -ENOMEM;
> +			}

The caller doesn't propogate the error code either so this doesn't
affect runtime, but generally we should propogate error codes.

	ret = atomisp_css_allocate_stat_buffers();
	if (ret) {
		kfree(s3a_buf);
		return ret;
	}

Same later as well...

regards,
dan carpenter


  reply	other threads:[~2026-01-07 14:31 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-04 16:40 [PATCH] media: atomisp: replace shadow zoom structs with v4l2_rect and fix error paths Karthikey D Kadati
2026-01-04 18:38 ` Hans de Goede
2026-01-05 14:57   ` [PATCH v2 0/3] media: atomisp: refactoring and fixes for V4L2 compliance Karthikey D Kadati
2026-01-05 14:57     ` [PATCH v2 1/3] media: atomisp: replace shadow zoom structs with v4l2_rect Karthikey D Kadati
2026-01-05 14:57     ` [PATCH v2 2/3] media: atomisp: consolidate statistics buffer allocation Karthikey D Kadati
2026-01-05 14:57     ` [PATCH v2 3/3] media: atomisp: propagate errors from ISP xnr and IRQ enable Karthikey D Kadati
2026-01-07 13:48   ` [PATCH v2 RESEND 0/3] media: atomisp: refactoring and fixes for V4L2 compliance Karthikey D Kadati
2026-01-07 13:48     ` [PATCH v2 RESEND v2 1/3] media: atomisp: replace shadow zoom structs with v4l2_rect Karthikey D Kadati
2026-01-07 14:20       ` Dan Carpenter
2026-01-07 13:48     ` [PATCH v2 RESEND v2 2/3] media: atomisp: consolidate statistics buffer allocation Karthikey D Kadati
2026-01-07 14:31       ` Dan Carpenter [this message]
2026-01-07 13:48     ` [PATCH v2 RESEND v2 3/3] media: atomisp: propagate errors from ISP xnr and IRQ enable Karthikey D Kadati
2026-01-07 14:33       ` Dan Carpenter
2026-01-07 14:22     ` [PATCH v2 RESEND 0/3] media: atomisp: refactoring and fixes for V4L2 compliance Dan Carpenter

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=aV5uJ-bB6wQcq3s6@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=hansg@kernel.org \
    --cc=karthikey3608@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --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