mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wentao Liang <vulab@iscas.ac.cn>
To: hverkuil@kernel.org, mchehab@kernel.org
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Wentao Liang <vulab@iscas.ac.cn>,
	stable@vger.kernel.org
Subject: [PATCH] media: saa7146: hexium_orion: Unwind failed attachment
Date: Tue,  3 Nov 2026 08:37:38 +0000	[thread overview]
Message-ID: <20261103083738.1180466-1-vulab@iscas.ac.cn> (raw)

hexium_probe() registers an I2C adapter and stores the allocated private
data in dev->ext_priv. If hexium_attach() then fails to initialize the VV
layer or register the video device, the core frees its own resources
without calling the extension's detach callback.

Release the I2C adapter and private data on both attachment failures, and
release the VV layer when video registration fails after successful VV
initialization. Clear the private pointer and return the actual video
registration error. This follows the cleanup already used for video
registration failure by the sibling Hexium Gemini driver.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/media/pci/saa7146/hexium_orion.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/media/pci/saa7146/hexium_orion.c b/drivers/media/pci/saa7146/hexium_orion.c
index 8ef2a4e8235d..95b3efee33ac 100644
--- a/drivers/media/pci/saa7146/hexium_orion.c
+++ b/drivers/media/pci/saa7146/hexium_orion.c
@@ -363,15 +363,16 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
 	ret = saa7146_vv_init(dev, &vv_data);
 	if (ret) {
 		pr_err("Error in saa7146_vv_init()\n");
-		return ret;
+		goto err_i2c;
 	}
 
 	vv_data.vid_ops.vidioc_enum_input = vidioc_enum_input;
 	vv_data.vid_ops.vidioc_g_input = vidioc_g_input;
 	vv_data.vid_ops.vidioc_s_input = vidioc_s_input;
-	if (0 != saa7146_register_device(&hexium->video_dev, dev, "hexium orion", VFL_TYPE_VIDEO)) {
+	ret = saa7146_register_device(&hexium->video_dev, dev, "hexium orion", VFL_TYPE_VIDEO);
+	if (ret) {
 		pr_err("cannot register capture v4l2 device. skipping.\n");
-		return -1;
+		goto err_vv;
 	}
 
 	pr_err("found 'hexium orion' frame grabber-%d\n", hexium_num);
@@ -383,6 +384,14 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
 	hexium_set_input(hexium, 0);
 
 	return 0;
+
+err_vv:
+	saa7146_vv_release(dev);
+err_i2c:
+	i2c_del_adapter(&hexium->i2c_adapter);
+	kfree(hexium);
+	dev->ext_priv = NULL;
+	return ret;
 }
 
 static int hexium_detach(struct saa7146_dev *dev)
-- 
2.34.1


             reply	other threads:[~2026-11-03  8:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03  8:37 Wentao Liang [this message]
2026-11-03  9:20 ` Krzysztof Kozlowski

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=20261103083738.1180466-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=hverkuil@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=stable@vger.kernel.org \
    /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®