ch: Make it again possible to open a ch device two or more times
Subsystems (2)
PATCH 1/1 ch: Make it again possible to open a ch device two or more times
Clearing ch->device in ch_release() is wrong because that pointer must remain valid until ch_remove() is called. This patch fixes the following crash the second time a ch device is opened:
BUG: kernel NULL pointer dereference, address: 0000000000000790 RIP: 0010:scsi_device_get+0x5/0x60 Call Trace: ch_open+0x4c/0xa0 [ch] chrdev_open+0xa2/0x1c0 do_dentry_open+0x13a/0x380 path_openat+0x591/0x1470 do_filp_open+0x91/0x100 do_sys_open+0x184/0x220 do_syscall_64+0x5f/0x1a0 entry_SYSCALL_64_after_hwframe+0x44/0xa9
Reported-by Rob Turk <[email protected]>
Suggested-by Rob Turk <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc <[email protected]>
Fixes 085e56766f74 ("scsi: ch: add refcounting")
Signed-off-by Bart Van Assche <[email protected]>
--- drivers/scsi/ch.c | 1 - 1 file changed, 1 deletion(-)
drivers/scsi/ch.c +0 -1
@@ -579,7 +579,6 @@ ch_release(struct inode *inode, struct file *file)scsi_changer *ch = file->private_data;scsi_device_put (ch->device); - ch->device =NULL ; file->private_data =NULL ;kref_put (&ch->ref, ch_destroy);return 0 ;
Signature · 1 line
2.23.0.581.g78d2f28ef7-goog
Martin K. Petersen
AppliedBart,
Quoted 3 lines
Clearing
ch->deviceinch_release()is wrong because that pointer must remain valid untilch_remove()is called. This patch fixes the following crash the second time a ch device is opened:
Applied to 5.4/scsi-fixes, thank you!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering