From: Geert Uytterhoeven <geert+renesas@glider.be>
To: Pantelis Antoniou <pantelis.antoniou@konsulko.com>,
Rob Herring <robh+dt@kernel.org>,
Frank Rowand <frowand.list@gmail.com>
Cc: Colin King <colin.king@canonical.com>,
Dan Carpenter <dan.carpenter@oracle.com>,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>
Subject: [PATCH v2 2/2] of: overlay: Fix cleanup order in of_overlay_apply()
Date: Mon, 4 Dec 2017 16:47:36 +0100 [thread overview]
Message-ID: <1512402456-8176-3-git-send-email-geert+renesas@glider.be> (raw)
In-Reply-To: <1512402456-8176-1-git-send-email-geert+renesas@glider.be>
The special overlay mutex is taken first, hence it should be released
last in the error path.
Move "mutex_lock(&of_mutex)" up, as suggested by Frank, as
free_overlay_changeset() should be called with that mutex held if any
non-trivial cleanup is to be done.
Merge the two tail statements of the success and error paths, now they
became identical.
Fixes: f948d6d8b792bb90 ("of: overlay: avoid race condition between applying multiple overlays")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
This is v2 of commit bd80e2555c5c9d45 ("of: overlay: Fix cleanup order
in of_overlay_apply()"), which was dropped by Rob.
---
drivers/of/overlay.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
index 312cd658bec0083b..0ddb7748ac85498f 100644
--- a/drivers/of/overlay.c
+++ b/drivers/of/overlay.c
@@ -705,12 +705,11 @@ int of_overlay_apply(struct device_node *tree, int *ovcs_id)
}
of_overlay_mutex_lock();
+ mutex_lock(&of_mutex);
ret = of_resolve_phandles(tree);
if (ret)
- goto err_overlay_unlock;
-
- mutex_lock(&of_mutex);
+ goto err_free_overlay_changeset;
ret = init_overlay_changeset(ovcs, tree);
if (ret)
@@ -754,17 +753,13 @@ int of_overlay_apply(struct device_node *tree, int *ovcs_id)
ret = ret_tmp;
}
- mutex_unlock(&of_mutex);
- of_overlay_mutex_unlock();
-
- goto out;
+ goto out_unlock;
err_free_overlay_changeset:
free_overlay_changeset(ovcs);
+out_unlock:
mutex_unlock(&of_mutex);
-
-err_overlay_unlock:
of_overlay_mutex_unlock();
out:
--
2.7.4
next prev parent reply other threads:[~2017-12-04 15:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-04 15:47 [PATCH v2 0/2] of: overlay: Fix of_overlay_apply() error path Geert Uytterhoeven
2017-12-04 15:47 ` [PATCH v2 1/2] of: overlay: Fix memory leak in " Geert Uytterhoeven
2017-12-05 2:07 ` Frank Rowand
2017-12-05 8:01 ` Geert Uytterhoeven
2017-12-05 10:49 ` Geert Uytterhoeven
2017-12-05 13:46 ` Frank Rowand
2017-12-05 13:45 ` Frank Rowand
2017-12-05 13:58 ` Geert Uytterhoeven
2017-12-05 22:47 ` Frank Rowand
2017-12-04 15:47 ` Geert Uytterhoeven [this message]
2017-12-04 19:35 ` [PATCH v2 2/2] of: overlay: Fix cleanup order in of_overlay_apply() Rob Herring
2017-12-04 19:45 ` Geert Uytterhoeven
2017-12-05 1:16 ` Frank Rowand
2017-12-05 2:25 ` Rob Herring
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=1512402456-8176-3-git-send-email-geert+renesas@glider.be \
--to=geert+renesas@glider.be \
--cc=colin.king@canonical.com \
--cc=dan.carpenter@oracle.com \
--cc=devicetree@vger.kernel.org \
--cc=frowand.list@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pantelis.antoniou@konsulko.com \
--cc=robh+dt@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).