public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: "Nicholas A. Bellinger" <nab@linux-iscsi.org>,
	Xiubo Li <lixiubo@cmss.chinamobile.com>
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: [PATCH] tcmu: Oops in unmap_thread_fn()
Date: Tue, 01 Aug 2017 20:09:17 +0000	[thread overview]
Message-ID: <20170801200917.brigs5x47eujfx7a@mwanda> (raw)

Calling list_del() on the iterator pointer in list_for_each_entry() will
cause an oops.  We need to user the _safe() version for that.

Fixes: c73d02f63c16 ("tcmu: Add fifo type waiter list support to avoid starvation")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 9258b7dd2c30..fd9fcea68d23 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -1985,7 +1985,7 @@ static struct target_backend_ops tcmu_ops = {
 
 static int unmap_thread_fn(void *data)
 {
-	struct tcmu_dev *udev;
+	struct tcmu_dev *udev, *tmp;
 	loff_t off;
 	uint32_t start, end, block;
 	static uint32_t free_blocks;
@@ -2056,7 +2056,7 @@ static int unmap_thread_fn(void *data)
 		 * for the global data pool blocks.
 		 */
 		mutex_lock(&root_udev_waiter_mutex);
-		list_for_each_entry(udev, &root_udev_waiter, waiter) {
+		list_for_each_entry_safe(udev, tmp, &root_udev_waiter, waiter) {
 			mutex_lock(&udev->cmdr_lock);
 			if (udev->waiting_blocks < free_blocks) {
 				mutex_unlock(&udev->cmdr_lock);

             reply	other threads:[~2017-08-01 20:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-01 20:09 Dan Carpenter [this message]
2017-08-02  3:25 ` [PATCH] tcmu: Oops in unmap_thread_fn() Xiubo Li
2017-08-03 17:35 ` Mike Christie
2017-08-06 23:27 ` Nicholas A. Bellinger
2017-11-08 22:41   ` Bryant G. Ly

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=20170801200917.brigs5x47eujfx7a@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=lixiubo@cmss.chinamobile.com \
    --cc=nab@linux-iscsi.org \
    --cc=target-devel@vger.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