linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: kc27041980@gmail.com
To: Philipp Reisner <philipp.reisner@linbit.com>,
	Lars Ellenberg <lars.ellenberg@linbit.com>,
	Jens Axboe <axboe@kernel.dk>
Cc: drbd-dev@lists.linbit.com, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org, KC27041980 <kc27041980@gmail.com>
Subject: [PATCH 1/1] block/drbd/drbd_debugfs.c: Protect &connection->kref with resource->req_lock
Date: Tue, 26 Nov 2019 10:04:18 +0530	[thread overview]
Message-ID: <1574742858-23131-1-git-send-email-KC17041980@gmail.com> (raw)

From: KC27041980 <kc27041980@gmail.com>

Protect &connection->kref by moving it under resource->req_lock.

Signed-off-by: KC27041980 <kc27041980@gmail.com>
---
 drivers/block/drbd/drbd_debugfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/block/drbd/drbd_debugfs.c b/drivers/block/drbd/drbd_debugfs.c
index b3b9cd5..f6d75fa 100644
--- a/drivers/block/drbd/drbd_debugfs.c
+++ b/drivers/block/drbd/drbd_debugfs.c
@@ -363,11 +363,15 @@ static int in_flight_summary_show(struct seq_file *m, void *pos)
 	struct drbd_connection *connection;
 	unsigned long jif = jiffies;
 
+	spin_lock_irq(&resource->req_lock);
 	connection = first_connection(resource);
 	/* This does not happen, actually.
 	 * But be robust and prepare for future code changes. */
-	if (!connection || !kref_get_unless_zero(&connection->kref))
+	if (!connection || !kref_get_unless_zero(&connection->kref)) {
+		spin_unlock_irq(&resource->req_lock);
 		return -ESTALE;
+	}
+	spin_unlock_irq(&resource->req_lock);
 
 	/* BUMP me if you change the file format/content/presentation */
 	seq_printf(m, "v: %u\n\n", 0);
-- 
2.7.4


             reply	other threads:[~2019-11-26  4:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26  4:34 kc27041980 [this message]
2019-11-26  9:57 ` [PATCH 1/1] block/drbd/drbd_debugfs.c: Protect &connection->kref with resource->req_lock Greg KH

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=1574742858-23131-1-git-send-email-KC17041980@gmail.com \
    --to=kc27041980@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=drbd-dev@lists.linbit.com \
    --cc=lars.ellenberg@linbit.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=philipp.reisner@linbit.com \
    /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).