All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][RESEND 2] component: enhance handling of devres group for master
@ 2018-07-26  6:06 bgoswami
  2018-07-26  8:26 ` Russell King - ARM Linux
  0 siblings, 1 reply; 2+ messages in thread
From: bgoswami @ 2018-07-26  6:06 UTC (permalink / raw)
  To: linux, gregkh
  Cc: linux-kernel, linux-arm-msm, srinivas.kandagatla, Banajit Goswami

From: Banajit Goswami <bgoswami@codeaurora.org>

The devres group opened for a master is left open-ended (without
devres_group_close) even after bind() is complete. Similarly, while
releasing the devres resources for master, the most recently opened
devres group is selected, and released without identifying the
targeted group. As the devres group opened before master bind was
never closed, there may have unintended consequences of releasing
devres resources that were allocated after master bind() function
was complete.

Change adds a devres_group_close() after bind() call to master, to
encapsulate the resources allocated during bind, and then use a
group ID to specifically identify the group in release, so that
during master unbind, only the resources that are part of that
specific devres group, are released.

Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
---
 drivers/base/component.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/base/component.c b/drivers/base/component.c
index 89b032f..f9ce937 100644
--- a/drivers/base/component.c
+++ b/drivers/base/component.c
@@ -155,17 +155,19 @@ static int try_to_bring_up_master(struct master *master,
 		return 0;
 	}
 
-	if (!devres_open_group(master->dev, NULL, GFP_KERNEL))
+	if (!devres_open_group(master->dev, master, GFP_KERNEL))
 		return -ENOMEM;
 
 	/* Found all components */
 	ret = master->ops->bind(master->dev);
 	if (ret < 0) {
-		devres_release_group(master->dev, NULL);
+		devres_release_group(master->dev, master);
 		dev_info(master->dev, "master bind failed: %d\n", ret);
 		return ret;
 	}
 
+	devres_close_group(master->dev, master);
+
 	master->bound = true;
 	return 1;
 }
@@ -190,7 +192,7 @@ static void take_down_master(struct master *master)
 {
 	if (master->bound) {
 		master->ops->unbind(master->dev);
-		devres_release_group(master->dev, NULL);
+		devres_release_group(master->dev, master);
 		master->bound = false;
 	}
 }
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project

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

* Re: [PATCH][RESEND 2] component: enhance handling of devres group for master
  2018-07-26  6:06 [PATCH][RESEND 2] component: enhance handling of devres group for master bgoswami
@ 2018-07-26  8:26 ` Russell King - ARM Linux
  0 siblings, 0 replies; 2+ messages in thread
From: Russell King - ARM Linux @ 2018-07-26  8:26 UTC (permalink / raw)
  To: bgoswami; +Cc: gregkh, linux-kernel, linux-arm-msm, srinivas.kandagatla

On Wed, Jul 25, 2018 at 11:06:28PM -0700, bgoswami@codeaurora.org wrote:
> From: Banajit Goswami <bgoswami@codeaurora.org>
> 
> The devres group opened for a master is left open-ended (without
> devres_group_close) even after bind() is complete. Similarly, while
> releasing the devres resources for master, the most recently opened
> devres group is selected, and released without identifying the
> targeted group. As the devres group opened before master bind was
> never closed, there may have unintended consequences of releasing
> devres resources that were allocated after master bind() function
> was complete.

... as intended, because this layers on top of the driver model.
You are aware that the driver model leaves its implicit group open
as well?

I think you need to explain why you need this - what is the problem
scenario that you are encountering.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 13.8Mbps down 630kbps up
According to speedtest.net: 13Mbps down 490kbps up

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

end of thread, other threads:[~2018-07-26  8:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26  6:06 [PATCH][RESEND 2] component: enhance handling of devres group for master bgoswami
2018-07-26  8:26 ` Russell King - ARM Linux

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.