public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	Andy Shevchenko <andy@kernel.org>
Cc: Hans de Goede <hdegoede@redhat.com>, Kate Hsuan <hpa@redhat.com>,
	Tsuchiya Yuto <kitakar@gmail.com>,
	Yury Luneff <yury.lunev@gmail.com>,
	Nable <nable.maininbox@googlemail.com>,
	andrey.i.trufanov@gmail.com, Fabio Aiuto <fabioaiuto83@gmail.com>,
	linux-media@vger.kernel.org, linux-staging@lists.linux.dev
Subject: [PATCH 07/15] media: atomisp: Fix probe error-exit path
Date: Sun, 31 Dec 2023 11:30:49 +0100	[thread overview]
Message-ID: <20231231103057.35837-8-hdegoede@redhat.com> (raw)
In-Reply-To: <20231231103057.35837-1-hdegoede@redhat.com>

Fix probe error-exit path:
-Add a missing ia_css_unload_firmware() call when v4l2_async_nf_register()
 fails
-Add a missing pm_runtime_forbid() call to undo the pm_runtime_allow() call
-Remove the unnecessary pcim_iounmap_regions() those are devm managed
 so they will get cleaned up automatically on an error exit from probe()
-Rename the labels to avoid having multiple labels pointing to the same
 place in the error-exit path

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 .../staging/media/atomisp/pci/atomisp_v4l2.c  | 39 +++++++++----------
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
index 0eea20704e66..336c5a895ecc 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c
@@ -1337,25 +1337,25 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 	if (!isp->firmware) {
 		err = -ENOENT;
 		dev_dbg(&pdev->dev, "Firmware load failed\n");
-		goto load_fw_fail;
+		goto error_power_off;
 	}
 
 	err = sh_css_check_firmware_version(isp->dev, isp->firmware->data);
 	if (err) {
 		dev_dbg(&pdev->dev, "Firmware version check failed\n");
-		goto fw_validation_fail;
+		goto error_release_firmware;
 	}
 
 	err = pcim_enable_device(pdev);
 	if (err) {
 		dev_err(&pdev->dev, "Failed to enable ISP PCI device (%d)\n", err);
-		goto pci_enable_fail;
+		goto error_release_firmware;
 	}
 
 	err = pcim_iomap_regions(pdev, BIT(ATOM_ISP_PCI_BAR), pci_name(pdev));
 	if (err) {
 		dev_err(&pdev->dev, "Failed to I/O memory remapping (%d)\n", err);
-		goto ioremap_fail;
+		goto error_release_firmware;
 	}
 
 	isp->base = pcim_iomap_table(pdev)[ATOM_ISP_PCI_BAR];
@@ -1365,7 +1365,7 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 	err = pci_alloc_irq_vectors(pdev, 1, 1, PCI_IRQ_MSI);
 	if (err < 0) {
 		dev_err(&pdev->dev, "Failed to enable msi (%d)\n", err);
-		goto enable_msi_fail;
+		goto error_release_firmware;
 	}
 
 	atomisp_msi_irq_init(isp);
@@ -1408,13 +1408,13 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 	err = atomisp_initialize_modules(isp);
 	if (err < 0) {
 		dev_err(&pdev->dev, "atomisp_initialize_modules (%d)\n", err);
-		goto initialize_modules_fail;
+		goto error_irq_uninit;
 	}
 
 	err = atomisp_register_entities(isp);
 	if (err < 0) {
 		dev_err(&pdev->dev, "atomisp_register_entities failed (%d)\n", err);
-		goto register_entities_fail;
+		goto error_uninitialize_modules;
 	}
 
 	INIT_WORK(&isp->assert_recovery_work, atomisp_assert_recovery_work);
@@ -1453,14 +1453,14 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 					IRQF_SHARED, "isp_irq", isp);
 	if (err) {
 		dev_err(&pdev->dev, "Failed to request irq (%d)\n", err);
-		goto request_irq_fail;
+		goto error_unregister_entities;
 	}
 
 	/* Load firmware into ISP memory */
 	err = atomisp_css_load_firmware(isp);
 	if (err) {
 		dev_err(&pdev->dev, "Failed to init css.\n");
-		goto css_init_fail;
+		goto error_free_irq;
 	}
 	/* Clear FW image from memory */
 	release_firmware(isp->firmware);
@@ -1470,33 +1470,32 @@ static int atomisp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 	err = v4l2_async_nf_register(&isp->notifier);
 	if (err) {
 		dev_err(isp->dev, "failed to register async notifier : %d\n", err);
-		goto css_init_fail;
+		goto error_unload_firmware;
 	}
 
 	atomisp_drvfs_init(isp);
 
 	return 0;
 
-css_init_fail:
+error_unload_firmware:
+	ia_css_unload_firmware();
+error_free_irq:
 	devm_free_irq(&pdev->dev, pdev->irq, isp);
-request_irq_fail:
+error_unregister_entities:
 	hmm_cleanup();
+	pm_runtime_forbid(&pdev->dev);
 	pm_runtime_get_noresume(&pdev->dev);
 	dev_pm_domain_set(&pdev->dev, NULL);
 	atomisp_unregister_entities(isp);
-register_entities_fail:
+error_uninitialize_modules:
 	atomisp_uninitialize_modules(isp);
-initialize_modules_fail:
+error_irq_uninit:
 	cpu_latency_qos_remove_request(&isp->pm_qos);
 	atomisp_msi_irq_uninit(isp);
 	pci_free_irq_vectors(pdev);
-enable_msi_fail:
-	pcim_iounmap_regions(pdev, BIT(ATOM_ISP_PCI_BAR));
-ioremap_fail:
-pci_enable_fail:
-fw_validation_fail:
+error_release_firmware:
 	release_firmware(isp->firmware);
-load_fw_fail:
+error_power_off:
 	/*
 	 * Switch off ISP, as keeping it powered on would prevent
 	 * reaching S0ix states.
-- 
2.43.0


  parent reply	other threads:[~2023-12-31 10:31 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-31 10:30 [PATCH 00/15] media: atomisp: NULL pointer deref + missing firmware fixes Hans de Goede
2023-12-31 10:30 ` [PATCH 01/15] media: atomisp: Adjust for v4l2_subdev_state handling changes in 6.8 Hans de Goede
2024-01-02  0:14   ` Andy Shevchenko
2023-12-31 10:30 ` [PATCH 02/15] media: atomisp: Refactor sensor crop + fmt setting Hans de Goede
2024-01-02  0:17   ` Andy Shevchenko
2023-12-31 10:30 ` [PATCH 03/15] media: atomisp: Remove s_routing subdev call Hans de Goede
2023-12-31 10:30 ` [PATCH 04/15] media: atomisp: Remove remaining deferred firmware loading code Hans de Goede
2023-12-31 10:30 ` [PATCH 05/15] media: atomisp: Drop is_valid_device() function Hans de Goede
2024-01-02  0:19   ` Andy Shevchenko
2024-02-19 13:25     ` Hans de Goede
2023-12-31 10:30 ` [PATCH 06/15] media: atomisp: Call pcim_enable_device() and pcim_iomap_regions() later Hans de Goede
2024-01-02  0:22   ` Andy Shevchenko
2023-12-31 10:30 ` Hans de Goede [this message]
2024-01-02  0:24   ` [PATCH 07/15] media: atomisp: Fix probe error-exit path Andy Shevchenko
2023-12-31 10:30 ` [PATCH 08/15] media: atomisp: Fix atomisp_pci_remove() Hans de Goede
2024-01-02  0:26   ` Andy Shevchenko
2023-12-31 10:30 ` [PATCH 09/15] media: atomisp: Group cpu_latency_qos_add_request() call together with other PM calls Hans de Goede
2023-12-31 10:30 ` [PATCH 10/15] media: atomisp: Fix probe()/remove() power-management Hans de Goede
2024-01-02  0:29   ` Andy Shevchenko
2023-12-31 10:30 ` [PATCH 11/15] media: atomisp: Replace atomisp_drvfs attr with using driver.dev_groups attr Hans de Goede
2024-01-02  0:33   ` Andy Shevchenko
2024-01-02 11:30     ` Hans de Goede
2024-01-02 21:23       ` Andy Shevchenko
2024-01-17 15:03         ` Hans de Goede
2023-12-31 10:30 ` [PATCH 12/15] media: atomisp: Move power-management [un]init into atomisp_pm_[un]init() Hans de Goede
2023-12-31 10:30 ` [PATCH 13/15] media: atomisp: Bind and do power-management without firmware Hans de Goede
2023-12-31 10:30 ` [PATCH 14/15] media: atomisp: Remove unnecessary msleep(10) from atomisp_mrfld_power() error path Hans de Goede
2023-12-31 10:30 ` [PATCH 15/15] media: atomisp: Update TODO Hans de Goede
2024-01-02  0:40 ` [PATCH 00/15] media: atomisp: NULL pointer deref + missing firmware fixes Andy Shevchenko

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=20231231103057.35837-8-hdegoede@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=andrey.i.trufanov@gmail.com \
    --cc=andy@kernel.org \
    --cc=fabioaiuto83@gmail.com \
    --cc=hpa@redhat.com \
    --cc=kitakar@gmail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=nable.maininbox@googlemail.com \
    --cc=sakari.ailus@linux.intel.com \
    --cc=yury.lunev@gmail.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