All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vaishnav Achath <vaishnav.a@ti.com>
To: <linux-media@vger.kernel.org>, <devicetree@vger.kernel.org>,
	<mripard@kernel.org>, <mchehab@kernel.org>, <robh+dt@kernel.org>,
	<krzysztof.kozlowski+dt@linaro.org>,
	<laurent.pinchart@ideasonboard.com>,
	<sakari.ailus@linux.intel.com>, <tomi.valkeinen@ideasonboard.com>
Cc: <linux-kernel@vger.kernel.org>, <bparrot@ti.com>,
	<niklas.soderlund+renesas@ragnatech.se>, <j-luthra@ti.com>,
	<devarsht@ti.com>, <praneeth@ti.com>, <u-kumar1@ti.com>,
	<vigneshr@ti.com>, <nm@ti.com>, <martyn.welch@collabora.com>,
	<vaishnav.a@ti.com>
Subject: [PATCH v7 01/13] media: cadence: csi2rx: Unregister v4l2 async notifier
Date: Tue, 14 Mar 2023 17:25:04 +0530	[thread overview]
Message-ID: <20230314115516.667-2-vaishnav.a@ti.com> (raw)
In-Reply-To: <20230314115516.667-1-vaishnav.a@ti.com>

From: Pratyush Yadav <p.yadav@ti.com>

The notifier is added to the global notifier list when registered. When
the module is removed, the struct csi2rx_priv in which the notifier is
embedded, is destroyed. As a result the notifier list has a reference to
a notifier that no longer exists. This causes invalid memory accesses
when the list is iterated over. Similar for when the probe fails.
Unregister and clean up the notifier to avoid this.

Fixes: 1fc3b37f34f6 ("media: v4l: cadence: Add Cadence MIPI-CSI2 RX driver")

Signed-off-by: Pratyush Yadav <p.yadav@ti.com>
Signed-off-by: Vaishnav Achath <vaishnav.a@ti.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---

(no changes since v5)

Changes in v5:
- Cleanup notifier in csi2rx_parse_dt() after the call to
  v4l2_async_nf_add_fwnode_remote().

Changes in v3:
- New in v3.

 drivers/media/platform/cadence/cdns-csi2rx.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/platform/cadence/cdns-csi2rx.c b/drivers/media/platform/cadence/cdns-csi2rx.c
index cc3ebb0d96f6..2a23da6a0b8e 100644
--- a/drivers/media/platform/cadence/cdns-csi2rx.c
+++ b/drivers/media/platform/cadence/cdns-csi2rx.c
@@ -404,8 +404,10 @@ static int csi2rx_parse_dt(struct csi2rx_priv *csi2rx)
 	asd = v4l2_async_nf_add_fwnode_remote(&csi2rx->notifier, fwh,
 					      struct v4l2_async_subdev);
 	of_node_put(ep);
-	if (IS_ERR(asd))
+	if (IS_ERR(asd)) {
+		v4l2_async_nf_cleanup(&csi2rx->notifier);
 		return PTR_ERR(asd);
+	}
 
 	csi2rx->notifier.ops = &csi2rx_notifier_ops;
 
@@ -467,6 +469,7 @@ static int csi2rx_probe(struct platform_device *pdev)
 	return 0;
 
 err_cleanup:
+	v4l2_async_nf_unregister(&csi2rx->notifier);
 	v4l2_async_nf_cleanup(&csi2rx->notifier);
 err_free_priv:
 	kfree(csi2rx);
@@ -477,6 +480,8 @@ static int csi2rx_remove(struct platform_device *pdev)
 {
 	struct csi2rx_priv *csi2rx = platform_get_drvdata(pdev);
 
+	v4l2_async_nf_unregister(&csi2rx->notifier);
+	v4l2_async_nf_cleanup(&csi2rx->notifier);
 	v4l2_async_unregister_subdev(&csi2rx->subdev);
 	kfree(csi2rx);
 
-- 
2.17.1


  reply	other threads:[~2023-03-14 11:56 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14 11:55 [PATCH v7 00/13] CSI2RX support on J721E Vaishnav Achath
2023-03-14 11:55 ` Vaishnav Achath [this message]
2023-03-14 11:55 ` [PATCH v7 02/13] media: cadence: csi2rx: Cleanup media entity properly Vaishnav Achath
2023-03-14 11:55 ` [PATCH v7 03/13] media: cadence: csi2rx: Add get_fmt and set_fmt pad ops Vaishnav Achath
2023-03-14 11:55 ` [PATCH v7 04/13] media: cadence: csi2rx: Add external DPHY support Vaishnav Achath
2023-03-31 13:19   ` Sakari Ailus
2023-03-14 11:55 ` [PATCH v7 05/13] media: cadence: csi2rx: Soft reset the streams before starting capture Vaishnav Achath
2023-03-14 11:55 ` [PATCH v7 06/13] media: cadence: csi2rx: Set the STOP bit when stopping a stream Vaishnav Achath
2023-03-14 11:55 ` [PATCH v7 07/13] media: cadence: csi2rx: Fix stream data configuration Vaishnav Achath
2023-03-14 11:55 ` [PATCH v7 08/13] media: cadence: csi2rx: Populate subdev devnode Vaishnav Achath
2023-03-14 11:55 ` [PATCH v7 09/13] media: cadence: csi2rx: Add link validation Vaishnav Achath
2023-03-14 11:55 ` [PATCH v7 10/13] media: ti: Add CSI2RX support for J721E Vaishnav Achath
2023-03-20 12:51   ` Jai Luthra
2023-03-24 18:14   ` Laurent Pinchart
2023-03-28  8:19     ` Vaishnav Achath
2023-04-04 11:43     ` Tomi Valkeinen
2023-03-31 13:27   ` Sakari Ailus
2023-03-14 11:55 ` [PATCH v7 11/13] media: dt-bindings: Make sure items in data-lanes are unique Vaishnav Achath
2023-03-14 11:55 ` [PATCH v7 12/13] media: dt-bindings: Add DT bindings for TI J721E CSI2RX driver Vaishnav Achath
2023-03-14 14:10   ` Rob Herring
2023-03-15  7:44   ` Krzysztof Kozlowski
2023-03-14 11:55 ` [PATCH v7 13/13] media: dt-bindings: Convert Cadence CSI2RX binding to YAML Vaishnav Achath
2023-03-15  7:45   ` Krzysztof Kozlowski
2023-03-20  5:34     ` Vaishnav Achath
2023-03-23 19:36 ` [PATCH v7 00/13] CSI2RX support on J721E Martyn Welch
2023-03-28  6:01   ` Jai Luthra
2023-03-29 15:17     ` Martyn Welch
2023-04-04  8:44 ` Tomi Valkeinen
2023-06-22  9:18   ` Julien Massot
2023-06-22 11:04     ` Jai Luthra

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=20230314115516.667-2-vaishnav.a@ti.com \
    --to=vaishnav.a@ti.com \
    --cc=bparrot@ti.com \
    --cc=devarsht@ti.com \
    --cc=devicetree@vger.kernel.org \
    --cc=j-luthra@ti.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=martyn.welch@collabora.com \
    --cc=mchehab@kernel.org \
    --cc=mripard@kernel.org \
    --cc=niklas.soderlund+renesas@ragnatech.se \
    --cc=nm@ti.com \
    --cc=praneeth@ti.com \
    --cc=robh+dt@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tomi.valkeinen@ideasonboard.com \
    --cc=u-kumar1@ti.com \
    --cc=vigneshr@ti.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.