Skip to contentSkip to conversation

block/drbd/drbd_debugfs.c: Protect &connection->kref with resource->req_lock

PATCH In review [email protected] 2 participants 2 messages Nov 26, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block/drbd/drbd_debugfs.c: Protect &connection->kref with resource->req_lock

From: KC27041980 <[email protected]>

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

---
 drivers/block/drbd/drbd_debugfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/block/drbd/drbd_debugfs.c +5 -1
index b3b9cd5..f6d75fa 100644
@@ -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);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 5 lines · On Tue, Nov 26, 2019 at 10:04:18AM +0530, [email protected] wrote:

From: KC27041980 <[email protected]>

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

We need a real name here, something you sign legal documents with. Please see the in-kernel documentation about submitting patches for all of the details.

thanks,

gre gk-h