public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] scsi: ufs: ufshcd-pltfrm: Use of_property_count_u32_elems() to get property length
@ 2024-08-08 17:07 Rob Herring (Arm)
  2024-08-08 17:09 ` Bart Van Assche
  2024-08-12 22:18 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Rob Herring (Arm) @ 2024-08-08 17:07 UTC (permalink / raw)
  To: James E.J. Bottomley, Martin K. Petersen
  Cc: Bart Van Assche, linux-scsi, linux-kernel

Replace of_get_property() with the type specific
of_property_count_u32_elems() to get the property length.

This is part of a larger effort to remove callers of of_get_property()
and similar functions. of_get_property() leaks the DT property data
pointer which is a problem for dynamically allocated nodes which may
be freed.

Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
v2:
 - Update subject to include 'ufshcd-pltfrm'
---
 drivers/ufs/host/ufshcd-pltfrm.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/ufs/host/ufshcd-pltfrm.c b/drivers/ufs/host/ufshcd-pltfrm.c
index 2e1eb898a27c..0c9b303ccfa0 100644
--- a/drivers/ufs/host/ufshcd-pltfrm.c
+++ b/drivers/ufs/host/ufshcd-pltfrm.c
@@ -31,7 +31,6 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
 	const char *name;
 	u32 *clkfreq = NULL;
 	struct ufs_clk_info *clki;
-	int len = 0;
 	size_t sz = 0;
 
 	if (!np)
@@ -50,15 +49,12 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
 	if (cnt <= 0)
 		goto out;
 
-	if (!of_get_property(np, "freq-table-hz", &len)) {
+	sz = of_property_count_u32_elems(np, "freq-table-hz");
+	if (sz <= 0) {
 		dev_info(dev, "freq-table-hz property not specified\n");
 		goto out;
 	}
 
-	if (len <= 0)
-		goto out;
-
-	sz = len / sizeof(*clkfreq);
 	if (sz != 2 * cnt) {
 		dev_err(dev, "%s len mismatch\n", "freq-table-hz");
 		ret = -EINVAL;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] scsi: ufs: ufshcd-pltfrm: Use of_property_count_u32_elems() to get property length
  2024-08-08 17:07 [PATCH v2] scsi: ufs: ufshcd-pltfrm: Use of_property_count_u32_elems() to get property length Rob Herring (Arm)
@ 2024-08-08 17:09 ` Bart Van Assche
  2024-08-12 22:18 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Van Assche @ 2024-08-08 17:09 UTC (permalink / raw)
  To: Rob Herring (Arm), James E.J. Bottomley, Martin K. Petersen
  Cc: linux-scsi, linux-kernel

On 8/8/24 10:07 AM, Rob Herring (Arm) wrote:
> Replace of_get_property() with the type specific
> of_property_count_u32_elems() to get the property length.
> 
> This is part of a larger effort to remove callers of of_get_property()
> and similar functions. of_get_property() leaks the DT property data
> pointer which is a problem for dynamically allocated nodes which may
> be freed.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] scsi: ufs: ufshcd-pltfrm: Use of_property_count_u32_elems() to get property length
  2024-08-08 17:07 [PATCH v2] scsi: ufs: ufshcd-pltfrm: Use of_property_count_u32_elems() to get property length Rob Herring (Arm)
  2024-08-08 17:09 ` Bart Van Assche
@ 2024-08-12 22:18 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2024-08-12 22:18 UTC (permalink / raw)
  To: Rob Herring (Arm)
  Cc: James E.J. Bottomley, Martin K. Petersen, Bart Van Assche,
	linux-scsi, linux-kernel


Rob,

> Replace of_get_property() with the type specific
> of_property_count_u32_elems() to get the property length.

Applied to 6.12/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-08-12 22:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-08 17:07 [PATCH v2] scsi: ufs: ufshcd-pltfrm: Use of_property_count_u32_elems() to get property length Rob Herring (Arm)
2024-08-08 17:09 ` Bart Van Assche
2024-08-12 22:18 ` Martin K. Petersen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox