All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Sven Peter <sven@kernel.org>, Janne Grunau <j@jannau.net>
Cc: Neal Gompa <neal@gompa.dev>,
	asahi@lists.linux.dev, linux-kernel@vger.kernel.org,
	Johan Hovold <johan@kernel.org>
Subject: [PATCH 2/2] soc: apple: sart: drop device reference after lookup
Date: Fri, 26 Sep 2025 16:31:32 +0200	[thread overview]
Message-ID: <20250926143132.6419-3-johan@kernel.org> (raw)
In-Reply-To: <20250926143132.6419-1-johan@kernel.org>

Holding a reference to a device does not prevent its driver data from
going away so there is no point in keeping the reference after looking
up the sart device.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/soc/apple/sart.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/soc/apple/sart.c b/drivers/soc/apple/sart.c
index afa111736899..6952afc41308 100644
--- a/drivers/soc/apple/sart.c
+++ b/drivers/soc/apple/sart.c
@@ -164,17 +164,11 @@ static int apple_sart_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static void apple_sart_put_device(void *dev)
-{
-	put_device(dev);
-}
-
 struct apple_sart *devm_apple_sart_get(struct device *dev)
 {
 	struct device_node *sart_node;
 	struct platform_device *sart_pdev;
 	struct apple_sart *sart;
-	int ret;
 
 	sart_node = of_parse_phandle(dev->of_node, "apple,sart", 0);
 	if (!sart_node)
@@ -192,14 +186,11 @@ struct apple_sart *devm_apple_sart_get(struct device *dev)
 		return ERR_PTR(-EPROBE_DEFER);
 	}
 
-	ret = devm_add_action_or_reset(dev, apple_sart_put_device,
-				       &sart_pdev->dev);
-	if (ret)
-		return ERR_PTR(ret);
-
 	device_link_add(dev, &sart_pdev->dev,
 			DL_FLAG_PM_RUNTIME | DL_FLAG_AUTOREMOVE_SUPPLIER);
 
+	put_device(&sart_pdev->dev);
+
 	return sart;
 }
 EXPORT_SYMBOL_GPL(devm_apple_sart_get);
-- 
2.49.1


  parent reply	other threads:[~2025-09-26 14:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-26 14:31 [PATCH 0/2] soc: apple: fix device leak on mbox lookup Johan Hovold
2025-09-26 14:31 ` [PATCH 1/2] soc: apple: mailbox: fix device leak on lookup Johan Hovold
2025-09-26 18:08   ` Markus Elfring
2025-09-26 14:31 ` Johan Hovold [this message]
2025-10-03 21:43 ` [PATCH 0/2] soc: apple: fix device leak on mbox lookup Neal Gompa
2025-10-13 16:34 ` Sven Peter

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=20250926143132.6419-3-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=asahi@lists.linux.dev \
    --cc=j@jannau.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=neal@gompa.dev \
    --cc=sven@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 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.