[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1633380.7F0afK1dbG@vostro.rjw.lan>
Date: Wed, 07 Sep 2016 01:09:36 +0200
From: "Rafael J. Wysocki" <rjw@...ysocki.net>
To: Marek Szyprowski <m.szyprowski@...sung.com>
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org,
iommu@...ts.linux-foundation.org,
linux-samsung-soc@...r.kernel.org,
linux-arm-kernel@...ts.infradead.org,
Joerg Roedel <joro@...tes.org>,
Inki Dae <inki.dae@...sung.com>, Kukjin Kim <kgene@...nel.org>,
Krzysztof Kozlowski <k.kozlowski@...sung.com>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@...sung.com>,
Ulf Hansson <ulf.hansson@...aro.org>,
Mark Brown <broonie@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH v2 06/10] driver core: Avoid endless recursion if device has more than one link
On Friday, June 17, 2016 08:26:56 AM Marek Szyprowski wrote:
> This patch fixes endless recursion, which happends when device has
> more than one link.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@...sung.com>
> ---
> drivers/base/core.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 215cd44de761..4e778539b750 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -57,7 +57,8 @@ static int device_reorder_to_tail(struct device *dev, void *not_used)
> device_pm_move_last(dev);
> device_for_each_child(dev, NULL, device_reorder_to_tail);
> list_for_each_entry(link, &dev->consumer_links, c_node)
> - device_reorder_to_tail(link->consumer, NULL);
> + if (link->consumer != dev)
> + device_reorder_to_tail(link->consumer, NULL);
>
> return 0;
> }
>
If I'm not mistaken, this should not be necessary unless dev has a link
pointing to itself as a consumer. That would be a bug, though.
I can add a WARN_ON() to catch this case, but then if there's a link from
a consumer of dev pointing back to dev as a consumer, that still will loop
forever.
I guess we need to detect circular dependencies and fail link creation in
such cases. Oh well.
Thanks,
Rafael
Powered by blists - more mailing lists