From: Richard Weinberger <richard@nod.at>
To: dedekind1@gmail.com
Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Richard Weinberger <richard@nod.at>
Subject: [PATCH 3/3] UBI: Fix possible deadlock in erase_worker()
Date: Mon, 22 Sep 2014 10:45:36 +0200 [thread overview]
Message-ID: <1411375536-20067-3-git-send-email-richard@nod.at> (raw)
In-Reply-To: <1411375536-20067-1-git-send-email-richard@nod.at>
If sync_erase() fails with EINTR, ENOMEM, EAGAIN or
EBUSY erase_worker() re-schedules the failed work.
This will lead to a deadlock because erase_worker() is called
with work_sem held in read mode. And schedule_erase() will take
this lock again.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
drivers/mtd/ubi/wl.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 253ec9b..637ffff 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1421,8 +1421,6 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
{
struct ubi_wl_entry *e = wl_wrk->e;
int pnum = e->pnum;
- int vol_id = wl_wrk->vol_id;
- int lnum = wl_wrk->lnum;
int err, available_consumed = 0;
if (shutdown) {
@@ -1459,21 +1457,15 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
}
ubi_err("failed to erase PEB %d, error %d", pnum, err);
- kfree(wl_wrk);
if (err == -EINTR || err == -ENOMEM || err == -EAGAIN ||
err == -EBUSY) {
- int err1;
-
/* Re-schedule the LEB for erasure */
- err1 = schedule_erase(ubi, e, vol_id, lnum, 0);
- if (err1) {
- err = err1;
- goto out_ro;
- }
+ __schedule_ubi_work(ubi, wl_wrk);
return err;
}
+ kfree(wl_wrk);
kmem_cache_free(ubi_wl_entry_slab, e);
if (err != -EIO)
/*
--
1.8.4.5
next prev parent reply other threads:[~2014-09-22 8:45 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-22 8:45 [PATCH 1/3] UBI: ubi_eba_read_leb: Remove in vain variable assignment Richard Weinberger
2014-09-22 8:45 ` [PATCH 2/3] UBI: wl: Rename cancel flag to shutdown Richard Weinberger
2014-09-22 8:45 ` Richard Weinberger [this message]
2014-09-26 10:40 ` [PATCH 3/3] UBI: Fix possible deadlock in erase_worker() Artem Bityutskiy
2014-09-29 22:22 ` Richard Weinberger
2014-09-26 10:46 ` [PATCH 1/3] UBI: ubi_eba_read_leb: Remove in vain variable assignment Artem Bityutskiy
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=1411375536-20067-3-git-send-email-richard@nod.at \
--to=richard@nod.at \
--cc=dedekind1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.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).