Blob Blame History Raw
From: Hannes Reinecke <hare@suse.de>
Date: Mon, 20 Apr 2015 11:28:58 +0200
Subject: ch: add missing mutex_lock()/mutex_unlock() in ch_release()
References: bsc#1124235
Patch-Mainline: never, SUSE specific

The 'ch_mutex" is meant to guard against modifications of
file->private_data, so we need to take in in ch_release() as
well as in ch_open().

[lduncan: refreshed to apply
 NOTE: this patch never made it upstream, and probably isn't needed,
       but it doesn't hurt anything, and in the spirit of not
       breaking this release, I will leave it in place.]

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/ch.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/scsi/ch.c
+++ b/drivers/scsi/ch.c
@@ -577,8 +577,10 @@ ch_release(struct inode *inode, struct f
 {
 	scsi_changer *ch = file->private_data;
 
+	mutex_lock(&ch_mutex);
 	scsi_device_put(ch->device);
 	file->private_data = NULL;
+	mutex_unlock(&ch_mutex);
 	kref_put(&ch->ref, ch_destroy);
 	return 0;
 }