Linux Media Controller development
 help / color / mirror / Atom feed
From: Manik Bajpai <manik.bajpai@intel.com>
To: linux-media@vger.kernel.org
Cc: sakari.ailus@linux.intel.com, antti.laakso@linux.intel.com,
	sarang.sapre@intel.com
Subject: [PATCH v1 1/4] media: ipu6: Free boot config on queue memory alloc failure
Date: Mon, 28 Sep 2026 17:26:43 +0530	[thread overview]
Message-ID: <20260928115646.77399-2-manik.bajpai@intel.com> (raw)
In-Reply-To: <20260928115646.77399-1-manik.bajpai@intel.com>

If the queue_mem allocation in ipu7_init_boot_config() fails, the
function returned -ENOMEM without freeing the boot_config buffer it
had already allocated. The current caller happens to clean up via
ipu7_fw_isys_cleanup() -> ipu7_release_boot_config() on any failure
from this function, so this is not an active leak today, but
ipu7_init_boot_config() should not rely on a specific caller undoing
its partial allocations.

Call the existing ipu7_release_boot_config() helper before returning,
so the function cleans up after itself on its own error path,
independent of what the caller does.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Manik Bajpai <manik.bajpai@intel.com>
---
 drivers/media/pci/intel/ipu6/ipu7-boot.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/pci/intel/ipu6/ipu7-boot.c b/drivers/media/pci/intel/ipu6/ipu7-boot.c
index 5bd5281ec107..225f802cfd1c 100644
--- a/drivers/media/pci/intel/ipu6/ipu7-boot.c
+++ b/drivers/media/pci/intel/ipu6/ipu7-boot.c
@@ -246,6 +246,7 @@ int ipu7_init_boot_config(struct ipu6_bus_device *adev,
 					  GFP_KERNEL, 0);
 	if (!fwctx->queue_mem) {
 		dev_err(dev, "Failed to allocate queue memory.\n");
+		ipu7_release_boot_config(adev);
 		return -ENOMEM;
 	}
 	fwctx->queue_mem_size = total_queue_size_aligned;
-- 
2.53.0


  reply	other threads:[~2026-09-28 11:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 11:56 [PATCH v1 0/4] media: ipu6: A few defensive fixes for ipu7 buttress, fw-com and mmu paths Manik Bajpai
2026-09-28 11:56 ` Manik Bajpai [this message]
2026-09-28 11:56 ` [PATCH v1 2/4] media: ipu6: Always run cleanup in ipu7 power on/off on timeout Manik Bajpai
2026-09-28 11:56 ` [PATCH v1 3/4] media: ipu6: Validate fw-com queue indices before use Manik Bajpai
2026-09-28 11:56 ` [PATCH v1 4/4] media: ipu6: Fix NULL deref in ipu6_mmu_iova_to_phys() Manik Bajpai
2026-09-28 12:08   ` Sakari Ailus
2026-09-29  8:31     ` [PATCH v2 0/4] media: ipu6: A few defensive fixes for ipu7 buttress, fw-com and mmu paths Manik Bajpai
2026-09-29  8:31       ` [PATCH v2 1/4] media: ipu6: Free boot config on queue memory alloc failure Manik Bajpai
2026-09-30  8:53         ` Sakari Ailus
2026-09-29  8:31       ` [PATCH v2 2/4] media: ipu6: Always run cleanup in ipu7 power on/off on timeout Manik Bajpai
2026-09-30 13:17         ` Antti Laakso
2026-09-29  8:31       ` [PATCH v2 3/4] media: ipu6: Validate fw-com queue indices before use Manik Bajpai
2026-09-29  8:31       ` [PATCH v2 4/4] media: ipu6: Fix NULL deref in ipu6_mmu_iova_to_phys() Manik Bajpai

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=20260928115646.77399-2-manik.bajpai@intel.com \
    --to=manik.bajpai@intel.com \
    --cc=antti.laakso@linux.intel.com \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=sarang.sapre@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